wxAuiNotebook::OnLeftUp not working Topic is solved
Re: wxAuiNotebook::OnLeftUp not working
I mean, i like to start just with one and only one page.
This page is intended a "add a page" page ("+" page).
I checked the changing event and it does not work, when you just have one page.
Most likely, because nothing can change.
Your code works, yes, i know. Once i have 2 or more pages, i get this event.
But not with just one page.
Do you know how i mean ?
Thank you
This page is intended a "add a page" page ("+" page).
I checked the changing event and it does not work, when you just have one page.
Most likely, because nothing can change.
Your code works, yes, i know. Once i have 2 or more pages, i get this event.
But not with just one page.
Do you know how i mean ?
Thank you
Re: wxAuiNotebook::OnLeftUp not working
I checked out the
Code: Select all
wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
It is not working, when you have just one page.
Re: wxAuiNotebook::OnLeftUp not working
Hi,
But did you actually run the code?
And as mentioned before - could you post your code from the minimal sample so we can see what is happenning?
Thank you.
But did you actually run the code?
And as mentioned before - could you post your code from the minimal sample so we can see what is happenning?
Thank you.
Re: wxAuiNotebook::OnLeftUp not working
This is not true, at least with wxWidgets 3.1.5 on MS Windows. When I comment out this linewxwxwx wrote: ↑Sun Apr 18, 2021 5:59 pm I checked out theevent.Code: Select all
wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
It is not working, when you have just one page.
Code: Select all
//m_notebook->AddPage(new wxPanel(m_notebook), "Page 1", true);
Re: wxAuiNotebook::OnLeftUp not working
So far i did not run your code, because have a linker problem.
My vcpkg wx version is 3.14.
But i checked this in my implmentation and event
did not work with one page.
My vcpkg wx version is 3.14.
But i checked this in my implmentation and event
Code: Select all
wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
Re: wxAuiNotebook::OnLeftUp not working
I just checked and it works with one page even with wxWidgets 3.0.5. The only change needed with this old version was to uninitialize wxAuiManager manually.
I do not understand how can you have issues with linking with my example code, as it cannot use anything else than your code does? Even if you are incapable of creating a test wxWidgets project, you should be able to just copy and paste those 30 lines of MyFrame code to your application and create an instance of MyFrame there.
If it does not work in your code, you must be doing something differently than in my code but I obviously cannot tell what it is.
I do not understand how can you have issues with linking with my example code, as it cannot use anything else than your code does? Even if you are incapable of creating a test wxWidgets project, you should be able to just copy and paste those 30 lines of MyFrame code to your application and create an instance of MyFrame there.
If it does not work in your code, you must be doing something differently than in my code but I obviously cannot tell what it is.
Re: wxAuiNotebook::OnLeftUp not working
Hm, could link now and run code with just one page and the
Code: Select all
wxEVT_AUINOTEBOOK_PAGE_CHANGING
Ok, thank you. Need to figure out the differences.
Re: wxAuiNotebook::OnLeftUp not working
This is absolutely a problem.
If a wxAuiNotebook page already has focus, a left click on the tab produces NO wxEVT_AUINOTEBOOK_PAGE_CHANGING event...it's not changing. Furthermore, the only way to capture it is with a wxEVT_LEFT_* which does not help as it does not indicate the tab.
This seems to be a strange and incomplete oversight as the right and middle are well supported:
If a wxAuiNotebook page already has focus, a left click on the tab produces NO wxEVT_AUINOTEBOOK_PAGE_CHANGING event...it's not changing. Furthermore, the only way to capture it is with a wxEVT_LEFT_* which does not help as it does not indicate the tab.
This seems to be a strange and incomplete oversight as the right and middle are well supported:
- EVT_AUINOTEBOOK_TAB_MIDDLE_*
- EVT_AUINOTEBOOK_TAB_RIGHT_*
Re: wxAuiNotebook::OnLeftUp not working
Why would you need to react to a click on a tab that's already active? Whatever you're doing will be bad UI design. No user will expect anything to happen there.
I'm almost certain you can determine the tab through wxAuiNotebook::GetActiveTabCtrl() and wxAuiTabContainer::TabHitTest(). (I haven't tried it though)Furthermore, the only way to capture it is with a wxEVT_LEFT_* which does not help as it does not indicate the tab.
Use the source, Luke!
Re: wxAuiNotebook::OnLeftUp not working
No. It's just a use case you haven't thought of.
The problem is that the page content loses focus when the tab is selected. I need to return focus to the page window to grab keystrokes...particularly LEFT, UP, DOWN, and RIGHT. I can control keyboard tab selection within the page window easily enough.
I can certainly determine the tab through wxAuiNotebook::GetActiveTabCtrl(). It's just a ass to elbow solution. Regardless, which event notifies the tab was selected when its page is currently selected? NONE! It's a corner case that could easily be solved with a EVT_AUINOTEBOOK_TAB_LEFT_DOWN/UP!
I need to set a EVT_LEFT_UP bind on the wxAuiTabCtrl for each page. So, when the page becomes active, I need to set and track the binding:
and unbind in a similar/opposite way when the page is closed.
Then,
This would be way easier if a EVT_AUINOTEBOOK_TAB_LEFT_DOWN/UP were available!
The problem is that the page content loses focus when the tab is selected. I need to return focus to the page window to grab keystrokes...particularly LEFT, UP, DOWN, and RIGHT. I can control keyboard tab selection within the page window easily enough.
I can certainly determine the tab through wxAuiNotebook::GetActiveTabCtrl(). It's just a ass to elbow solution. Regardless, which event notifies the tab was selected when its page is currently selected? NONE! It's a corner case that could easily be solved with a EVT_AUINOTEBOOK_TAB_LEFT_DOWN/UP!
I need to set a EVT_LEFT_UP bind on the wxAuiTabCtrl for each page. So, when the page becomes active, I need to set and track the binding:
Code: Select all
// Bind this active tab if not set...
if ( !this->m_CurrentPage->hasTabBind() ) {
this->m_auiNotebook.GetActiveTabCtrl()->Bind( wxEVT_LEFT_UP, &MainFrame::OnMouseLeftUp, this );
this->m_CurrentPage->setTabBind(true);
}
Then,
Code: Select all
void MainFrame::OnMouseLeftUp(wxMouseEvent &eventMouse)
{
// For wxAuiTabCtrl...
// NOTE: Use mouse EVT_LEFT_UP since the focus occurs between EVT_LEFT_DOWN and EVT_LEFT_UP.
// If EVT_LEFT_DOWN were used, the event happens before the focus is set.
wxWindow * pWin = wxWindow::FindFocus();
if (pWin) {
wxClassInfo * pInfo = pWin->GetClassInfo();
const wxString strClassName = wxString( pInfo->GetClassName() );
if (strClassName == L"wxAuiTabCtrl" ) {
this->CallAfter(
[this] {
if ( this->m_auiNotebook.GetSelection() != wxNOT_FOUND ) {
this->m_auiNotebook.GetCurrentPage()->SetFocus();
std::wcout << L"DEBUG: MainFrame::OnMouseLeftUp() : Lambda : SetFocus\n";
}
}
);
}
}
else {
std::wcout << L"DEBUG: MainFrame::OnMouseLeftUp() : Class: No CLass Found!\n";
}
eventMouse.Skip();
}
Re: wxAuiNotebook::OnLeftUp not working
Any why can't you just focus the page after receiving the wxEVT_AUINOTEBOOK_PAGE_CHANGED event?
Use the source, Luke!
Re: wxAuiNotebook::OnLeftUp not working
As said before, the wxEVT_AUINOTEBOOK_PAGE_CHANGED event does NOT fire when the selected tab is ALREADY on the selected page. It's NOT changing pages. I've have code already in place looking for that event.
No dice! Nada! Doesn't happen!
Code: Select all
this->Bind( wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainFrame::OnChangedPage, this );
Re: wxAuiNotebook::OnLeftUp not working
Now to add insult to injury, the MainFrame::OnMouseLeftUp method is called for the count of tabs in the notebook. BUT not on each tab--on the selected tab.
I optimized the code a bit to check it...
With 3 pages open, I select the page area of the current page to make sure its ALREADY focused, then I select that page's tab title and get:
Note that no messages occur from these bound methods:
UPDATE: Apparently, the wxAuiTabCtrl is a single control for the entire wxAuiNotebook and has no public methods to access the individual tabs. So, I wasted my time on creating multiple binds when creating each page as well as checking the wxAuiTabCtrl. One would suffice. That is why I got multiple EVT_LEFT_UP. i've changed the code to Bind once and I don't need to track anymore.
I optimized the code a bit to check it...
Code: Select all
void MainFrame::OnMouseLeftUp(wxMouseEvent &eventMouse)
{
// For wxAuiTabCtrl...
// NOTE: Use mouse EVT_LEFT_UP since the focus occurs between EVT_LEFT_DOWN and EVT_LEFT_UP.
// If EVT_LEFT_DOWN were used, the event happens before the focus is set.
wxWindow * pWin = wxWindow::FindFocus();
if (pWin) {
wxClassInfo * pInfo = pWin->GetClassInfo();
if ( pInfo->IsKindOf( CLASSINFO(wxAuiTabCtrl) ) ) {
wxAuiTabCtrl * pTab = (wxAuiTabCtrl *)pWin;
if ( this->m_auiNotebook.GetActiveTabCtrl() == pTab ) {
this->CallAfter(
[this] {
if ( this->m_auiNotebook.GetSelection() != wxNOT_FOUND ) {
this->m_auiNotebook.GetCurrentPage()->SetFocus();
std::wcout << L"DEBUG: MainFrame::OnMouseLeftUp() : Lambda : SetFocus\n";
}
}
);
}
}
}
else {
std::wcout << L"DEBUG: MainFrame::OnMouseLeftUp() : Class: No Class Found!\n";
}
eventMouse.Skip();
}
Code: Select all
DEBUG: MainFrame::OnMouseLeftUp() : Lambda : SetFocus
DEBUG: MainFrame::OnMouseLeftUp() : Lambda : SetFocus
DEBUG: MainFrame::OnMouseLeftUp() : Lambda : SetFocus
Code: Select all
this->Bind( wxEVT_AUINOTEBOOK_PAGE_CHANGING, &MainFrame::OnChangingPage, this );
this->Bind( wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainFrame::OnChangedPage, this );
Re: wxAuiNotebook::OnLeftUp not working
I'm documenting in full the "more" simplified solution...
1. After the wxAuiNotebook is added via the wxAuiManager, Bind the notebook's wxAuiTabCtrl:
2. Do similar to Unbind on clean up:
3. Code the OnTabLeftUp method to handle the tab selection:
This could be condensed a bit, but it provides the control for selecting the tab on the current page.
For selecting the other non-current tabs, the wxEVT_AUINOTEBOOK_PAGE_CHANGING and wxEVT_AUINOTEBOOK_PAGE_CHANGED event Binds provide the complete solution.
1. After the wxAuiNotebook is added via the wxAuiManager, Bind the notebook's wxAuiTabCtrl:
Code: Select all
this->m_auiNotebook.GetActiveTabCtrl()->Bind( wxEVT_LEFT_UP, &MainFrame::OnTabLeftUp, this );
Code: Select all
this->m_auiNotebook.GetActiveTabCtrl()->Unbind( wxEVT_LEFT_UP, &MainFrame::OnTabLeftUp, this );
Code: Select all
void MainFrame::OnTabLeftUp(wxMouseEvent &eventMouse)
{
// For wxAuiTabCtrl...
// NOTE: Use mouse EVT_LEFT_UP since the focus occurs between EVT_LEFT_DOWN and EVT_LEFT_UP.
// If EVT_LEFT_DOWN were used, the event happens before the focus is set.
wxWindow * pWin = wxWindow::FindFocus();
if (pWin) {
wxClassInfo * pInfo = pWin->GetClassInfo();
if ( pInfo->IsKindOf( CLASSINFO(wxAuiTabCtrl) ) ) {
this->CallAfter(
[this] {
if ( this->m_auiNotebook.GetSelection() != wxNOT_FOUND ) {
this->m_auiNotebook.GetCurrentPage()->SetFocus();
std::wcout << L"DEBUG: MainFrame::OnTabLeftUp() : Lambda : SetFocus\n";
}
}
);
}
}
else {
std::wcout << L"DEBUG: MainFrame::OnTabLeftUp() : Class: No Class Found!\n";
}
eventMouse.Skip();
}
For selecting the other non-current tabs, the wxEVT_AUINOTEBOOK_PAGE_CHANGING and wxEVT_AUINOTEBOOK_PAGE_CHANGED event Binds provide the complete solution.