wx.lib.customtreectrl and wx.EVT_CONTEXT_MENU bug

On windows if you "Bind" wx.lib.customtreecontrol with

self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)

it's working fine but on Linux it's not. I checked in Demo and there
context menu is Bind using mouse right up event. I haven't noticed
this until I checked my app on Linux.

Thanks

Prashant

#---- System Information ----#
Operating System: Linux 2.6.31-14-generic i686
Python Version: 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1]
wxPython Version: 2.8.10.1 (gtk2-unicode)
wxPython Info: (__WXGTK__, wxGTK, unicode, gtk2, wx-assertions-off,
SWIG-1.3.29)
Python Encoding: Default=UTF-8 File=UTF-8
wxPython Encoding: utf-8
System Architecture: 32bit i686
Byte order: little
Frozen: False
#---- End System Information ----

If the widget consumes the right-up event then the context menu event may not be sent. With generic controls it's easy to forget to Skip the mouse events and allow the system to do further default processing (like send the context menu event.) That is probably what is going on here.

···

On 2/21/10 6:51 AM, King wrote:

On windows if you "Bind" wx.lib.customtreecontrol with

self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)

it's working fine but on Linux it's not. I checked in Demo and there
context menu is Bind using mouse right up event. I haven't noticed
this until I checked my app on Linux.

--
Robin Dunn
Software Craftsman

Hi All,

On windows if you "Bind" wx.lib.customtreecontrol with

self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)

it's working fine but on Linux it's not. I checked in Demo and there
context menu is Bind using mouse right up event. I haven't noticed
this until I checked my app on Linux.

If the widget consumes the right-up event then the context menu event may
not be sent. With generic controls it's easy to forget to Skip the mouse
events and allow the system to do further default processing (like send the
context menu event.) That is probably what is going on here.

As far as I can see, CustomTreeCtrl Skip()s the mouse event if it's
not an interesting one, i.e.:

if not (event.LeftDown() or event.LeftUp() or event.RightDown() or
event.LeftDClick() or \
    event.Dragging() or ((event.Moving() or event.RightUp()) and
self._isDragging)):

    event.Skip()
    return

I am not sure what is going on, but a quick test would be to put an
event.Skip() at the end of the OnMouse() event handler and see if the
wx. EVT_CONTEXT_MENU event is sent. Sorry no Linux here at the
moment...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 22 February 2010 21:03, Robin Dunn wrote:

On 2/21/10 6:51 AM, King wrote: