[wxPython-users] [Fwd: [wxPython-dev] Grid cell editing and button
events (MSW)]
Robin Dunn
robin at alldunn.com
Fri Sep 1 15:55:00 PDT 2006
David Hughes wrote:
> I posted this to wxPython-dev a couple of weeks ago but didn't get any
> response.
Sorry, I've been procrastinating on my wxPython-dev email for a while...
> On a panel containing button(s) and a grid that has CellEditor(s), the
> buttons don't generate wx.EVT_BUTTON events if they are clicked while an
> editor is active.
>
> A short, stand-alone example is attached that also contains a fuller
> description of the problem. As far as I can test, it is MSW only.
>
> ------------------------------------------------------------------------
>
> # Module: TestGrid.py
> #
> # Function: Test grid - button problem
> #
> # Behaviour on MSW at wx 2.6.1.0+ has changed. When in a grid cell editor
> # clicking button closes and saves the edited value (internal use
> # of kill-focus?) but EVT_BUTTON event does not appear - work around by
> # catching button.EVT_LEFT_UP.
The EVT_KILL_FOCUS handler for the edit control calls
DisableCellEditControl which calls HideCellEditControl which calls the
GridWindow's SetFocus. Apparently the native button on Windows won't
respond to the mouse click by sending the button event if it does not
currently have the focus. I don't know if this should be considered a
bug or not...
You can also work around this by using a wx.lib.buttons.GenButton
instead of the native button.
> # Conversely if the button is set as the default,
> # pressing ENTER while in a grid editor terminates the edit but also
> # triggers the button - work around by having no default button.
This is expected since the panel will take the Enter key and use it for
navigation by looking for a default item. Since it finds the default
button it activates it and then eats the key event. You can also work
around it by creating the panel without the default wx.TAB_TRAVERSAL style.
> #
> # Also noticed that if the first button click is when a non-edit
> # grid cell is selected, only get a mouse event - but get both
> # events on subsequent clicks.
I get both of them on the first click with wxPython 2.6.3.3.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list