[wxPython-users] wxGrid editing odds
Andrea Gavana
andrea.gavana at gmail.com
Mon Mar 5 01:59:05 PST 2007
Hi Robin,
On 3/2/07, Robin Dunn wrote:
> Andrea Gavana wrote:
<snip>
<snap>
> Ctrl-Enter is indeed being used as a navigation key in wxMSW, and it
> looks like there are several places in the code that are ensuring that
> this is always the case, (so it wouldn't be easy to disable it.) I'll
> check on wx-dev to make sure I'm not missing something, but in the
> meantime I'd recommend just taking charge and giving your grid editor
> another way to insert a newline, such as Shift-Enter.
>
> self.grid.Bind(wx.grid.EVT_GRID_EDITOR_CREATED,
> self.OnEditorCreated)
>
> def OnEditorCreated(self, evt):
> def HandleShiftEnter(evt):
> if evt.KeyCode == wx.WXK_RETURN and evt.ShiftDown():
> evt.GetEventObject().WriteText('\n')
> else:
> evt.Skip()
>
> # This should probably only be done for cells that are using
> # the GridCellAutoWrapStringEditor but for this sample we'll
> # just do it for all...
>
> # Since the grid pushes a new wx.EvtHandler onto the control's
> # event ahndler stack, Bind to the first event handler on the
> # stack instead of directly to the control so we can get first
> # crack at the event.
> ctrlEH = evt.GetControl().GetEventHandler()
> ctrlEH.Bind(wx.EVT_KEY_DOWN, HandleShiftEnter)
Thank you for the sample! I am actually doing it with the Alt instead
of Shift, as M$ Excel does, but the result is the same :-D
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
More information about the wxpython-users
mailing list