Hi all
Robin recently helped me to get a GridCellBoolEditor to behave the same as a
normal CheckBox - i.e. you can toggle the CheckBox with a single mouse
click, and you can get access to the CheckBox event when it is activated.
I got it working in a stand-alone test program, but when I moved it to my
live app I found a problem with MSW (GTK2 works correctly). If the cell with
the checkbox has focus, I want to navigate off the cell using the arrow
keys, as is normal with a grid. In my test program, I initially found that
it did not respond to the arrow keys at all, but then I found that if I
create a handler for EVT_KEY_DOWN I can trap the arrow key, close the
editor, and force a navigation. In my live app, EVT_KEY_DOWN does not get
trigggered by the arrow key, the editor is closed automatically, and the
cursor stays on the cell.
I found that the difference is caused by the difference in window hierarchy.
My test app looks like this -
Frame
>
-- Panel (style=0)
>
-- Grid
My live app looks like this -
Frame
>
-- Panel (normal style)
>
-- TextCtrl
>
-- Sub-Panel (style=0)
>
-- Grid
You can see the difference in the attached programs. fm51.py is my original
test program, which works the way I want. fm52.py is modified to resemble my
live app. The only difference is on creation of the frame -
fm51.py has this -
panel = wx.Panel(self,style=0)
grid = MyGrid(panel)
fm52.py has this -
panel = wx.Panel(self)
wx.TextCtrl(panel,-1,size=(60,-1))
panel2 = wx.Panel(panel,pos=(10,30),size=(300,200),style=0)
grid = MyGrid(panel2)
I have figured out part of the reason. With MSW, if a normal CheckBox has
focus, it responds to the arrow keys - down and right are treated like tab,
up and left are treated like shift+tab. GTK2 does not do this - it ignores
the arrow keys and only responds to tab and shift+tab.
It seems that on MSW the GridCellBoolEditor is doing something similar - the
checkbox responds to the arrow key by closing the editor. This is the effect
that you see if you run fm52. Why it does not do this in fm51 I have no
idea. Is there any way to modify fm52 so that it behaves the same as fm51?
Thanks
Frank Millman
fm51.py (2.74 KB)
fm52.py (2.85 KB)