I’m trying to modify the keys that can be used to start editing a custom grid cell editor.
I’ve noticed the following function on wxWidgets sources:
// return true to allow the given key to start editing: the base class // version only checks that the event has no modifiers. The derived // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in // their IsAcceptedKey() implementation, although, of course, it is not a // mandatory requirment. // // NB: if the key is F2 (special), editing will always start and this // method will not be called at all (but StartingKey() will) virtual bool IsAcceptedKey(wxKeyEvent& event);
It is referenced on wxPython demo for custom editors (
def IsAcceptedKey(self, evt): """ Return True to allow the given key to start editing: the base class version only checks that the event has no modifiers. F2 is special and will always start the editor. """ self.log.write("MyCellEditor: IsAcceptedKey: %d\n" % (evt.GetKeyCode())) ## We can ask the base class to do it #return super(MyCellEditor, self).IsAcceptedKey(evt) # or do it ourselves return (not (evt.ControlDown() or evt.AltDown()) and evt.GetKeyCode() != wx.WXK_SHIFT)
But I can’t get it to work. When I run the demo and begin edits using key presses, the log doesn’t show any traces of “IsAcceptedKey”. Modifying the function to return False changes nothing.
I’m on tag
wxPython-4.0.7 running on python 2.7
Any help please?