Reading the reply of Iacopo on list, i think that a new thread for
this bug is too important.
Suppose to have a notebook with a event EVT_NOTEBOOK_PAGE_CHANGING
registered; in windows when I click from the tab 0 to tab 1 I got by
the event.GetOldSelection , event.GetSelection and
notebook.GetSelection respective old = 0 new=0 sel = 0.
Instead in Linux I correctly get old = 0, new= 1 sel = 0.
I noticed it comparing the wxDemos apps with the notebook module on
both Windows and Linux.
I also noticed that in Windows each event, it catches and printed two times.
Not equal to linux one.
Thanks all for interesting on this problem... It's too important for
me because my application must be cross-platform...
Regards.
···
--
Marco Meoni (Sbaush)
Marco Meoni - Sbaush wrote:
Reading the reply of Iacopo on list, i think that a new
thread for this bug is too important.
Suppose to have a notebook with a event
EVT_NOTEBOOK_PAGE_CHANGING registered; in windows when I
click from the tab 0 to tab 1 I got by the
event.GetOldSelection , event.GetSelection and
notebook.GetSelection respective old = 0 new=0 sel = 0.
Instead in Linux I correctly get old = 0, new= 1 sel = 0.
The following is taken from the C++ docs distributed with wxWidgets -
···
-----------------------------
wxNotebookEvent::GetSelection
int GetSelection() const
Returns the currently selected page, or -1 if none was selected.
NB: under Windows, GetSelection() will return the same value as
GetOldSelection() when called from EVT_NOTEBOOK_PAGE_CHANGING handler and
not the page which is going to be selected. Also note that the values of
selection and old selection returned for an event generated in response to a
call to wxNotebook::SetSelection shouldn't be trusted as they are currently
inconsistent under different platforms (but in this case you presumably
don't need them anyhow as you already have the corresponding information).
-----------------------------
It seems that this is the native behaviour under Windows, and therefore
there is nothing that wxWidgets or wxPython can do about it.
As far as I can tell, EVT_NOTEBOOK_PAGE_CHANGED behaves correctly. Can you
use this instead? If not, try the following.
I had the same problem before I switched to EVT_NOTEBOOK_PAGE_CHANGED, and I
found a workaround. I found that, of the various methods of switching to a
new page, only a mouse click gave this error - all other methods returned
the new selection correctly. Therefore I created the following handler for
EVT_LEFT_DOWN -
def OnLeftDown(self,evt):
page = self.HitTest(evt.GetPosition())[0]
if page > -1: # else clicked on blank area
self.new_page = page
evt.Skip()
Then in my EVT_NOTEBOOK_PAGE_CHANGING handler I had -
old = evt.GetOldSelection()
new = evt.GetSelection()
if old == new:
new = self.new_page
HTH
Frank Millman