Bug in MSW port

I believe that I have discovered a bug in the following scenario:

Python 2.3
wxPython 2.4.2.4
Windows 2000

What happens is that if you right click on the list control, the menu is
popped up not once, but twice. It appears that the right click event is
being generated twice. This only happens on Windows. With the exact same
configuration as above, except running Fedora Core 1 (or Red Hat 9) the
code works as expected. It does appear to be important how many
"nesting" levels there are as well. If I do not put the list control in
the notebook things appear to work correctly on Windows as well. Any
suggestions as to how to work around this problem or telling me that it
will be fixed in <fill in version here> would be appreciated. :slight_smile:

Attached is some simple code that demonstrates the problem.

list_rc.py (1.25 KB)

···

--
Anthony Tuininga
anthony@computronix.com

Computronix
Distinctive Software. Real People.
Suite 200, 10216 - 124 Street NW
Edmonton, AB, Canada T5N 4A3
Phone: (780) 454-3700
Fax: (780) 454-3838
http://www.computronix.com

Anthony Tuininga wrote:

I believe that I have discovered a bug in the following scenario:

Python 2.3
wxPython 2.4.2.4
Windows 2000

What happens is that if you right click on the list control, the menu is
popped up not once, but twice. It appears that the right click event is
being generated twice. This only happens on Windows. With the exact same
configuration as above, except running Fedora Core 1 (or Red Hat 9) the
code works as expected. It does appear to be important how many
"nesting" levels there are as well. If I do not put the list control in
the notebook things appear to work correctly on Windows as well. Any
suggestions as to how to work around this problem or telling me that it
will be fixed in <fill in version here> would be appreciated. :slight_smile:

Attached is some simple code that demonstrates the problem.

[...]

    def OnRightClick(self, event):
        menu = wx.Menu()
        menu.Append(1000, "Do something")
        wx.EVT_MENU(self.frame, 1000, self.OnDoSomething)
        self.list.PopupMenu(menu, event.GetPoint())
        menu.Destroy()
        event.Skip()

Don't call event.Skip and the handler won't be called again. Not sure why this specific case is doing it but it could be the age-old problem of working around a bug in one version of the MS common controls only to have the work around do something like you are seeing in other verisons of the common controls. wxWindows philosophy is that it is better to get the event twice than not at all.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Your suggestion of eliminating the event.Skip() does indeed do the
trick. I have another case where this happens but the other way around.
In this case, a tree view will not get the right click event unless you
remove the event.Skip() call or actually double right click. Rather
bizarre if you ask me. I wonder what will happen on Windows 98.... :slight_smile:

I have attached the modified test case that shows both problems. I don't
know if you think this should be logged as a bug somewhere or simply
ignored? Your call.... :slight_smile:

list_rc.py (2.01 KB)

···

On Tue, 2003-11-18 at 20:34, Robin Dunn wrote:

Anthony Tuininga wrote:
> I believe that I have discovered a bug in the following scenario:
>
> Python 2.3
> wxPython 2.4.2.4
> Windows 2000
>
> What happens is that if you right click on the list control, the menu is
> popped up not once, but twice. It appears that the right click event is
> being generated twice. This only happens on Windows. With the exact same
> configuration as above, except running Fedora Core 1 (or Red Hat 9) the
> code works as expected. It does appear to be important how many
> "nesting" levels there are as well. If I do not put the list control in
> the notebook things appear to work correctly on Windows as well. Any
> suggestions as to how to work around this problem or telling me that it
> will be fixed in <fill in version here> would be appreciated. :slight_smile:
>
> Attached is some simple code that demonstrates the problem.
>
>

[...]

>
> def OnRightClick(self, event):
> menu = wx.Menu()
> menu.Append(1000, "Do something")
> wx.EVT_MENU(self.frame, 1000, self.OnDoSomething)
> self.list.PopupMenu(menu, event.GetPoint())
> menu.Destroy()
> event.Skip()

Don't call event.Skip and the handler won't be called again. Not sure
why this specific case is doing it but it could be the age-old problem
of working around a bug in one version of the MS common controls only to
have the work around do something like you are seeing in other verisons
of the common controls. wxWindows philosophy is that it is better to
get the event twice than not at all.

--
Anthony Tuininga
anthony@computronix.com

Computronix
Distinctive Software. Real People.
Suite 200, 10216 - 124 Street NW
Edmonton, AB, Canada T5N 4A3
Phone: (780) 454-3700
Fax: (780) 454-3838