Howdy,
I did my best to search the archives for this question, but came up blank, so...
I am using the Enthought\TraitsGui framework which uses wxPython. My problem
is that I have a keybinding for the delete key in a tree control that deletes
the selected node.
Unfortunately, due to the way TGUI works if I have a right panel
TextEditor (TextCtrl) open and am editing and use the delete key, the keybinding
is executed first so that the node is deleted instead of the correct character
in the TextCtrl being deleted.
My solution to this is in the keybinding code to determine if the textctrl
is actively being edited. Is there a method to determine if a TextCtrl is
actively being edited? I know the standard way would be to respond to an event,
but I can't do this. I need to programatically interrogate the control, not
passively respond to an event.
thanks,
Danny
Sorry, but AFAIK HasFocus, that exists in other programming languages such as Visual Basic and Visual C++, is not an attribute of wx.Window in wx.Python.
But if the problem is to know whether the TextCtrl has focus, it is possible to handle the events wx.EVT_SET:FOCUS and wx.EVT_LOST_FOCUS, enabling and disabling a variable like self.textHAS_FOCUS.
···
2009/1/7 Udo Müller wxpyu-1208@mueller-udo.de
Hi
Am 07.01.2009 um 17:38 schrieb Danny Shevitz shevitz@lanl.gov:
Howdy,
I did my best to search the archives for this question, but came up blank, so…
I am using the Enthought\TraitsGui framework which uses wxPython. My problem
is that I have a keybinding for the delete key in a tree control that deletes
the selected node.
Unfortunately, due to the way TGUI works if I have a right panel
TextEditor (TextCtrl) open and am editing and use the delete key, the keybinding
is executed first so that the node is deleted instead of the correct character
in the TextCtrl being deleted.
My solution to this is in the keybinding code to determine if the textctrl
is actively being edited. Is there a method to determine if a TextCtrl is
actively being edited? I know the standard way would be to respond to an event,
but I can’t do this. I need to programatically interrogate the control, not
passively respond
I am a noob but i think you should check if the tree HasFocus() and if it has delete the node.
Udo
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
raffaello wrote:
Sorry, but AFAIK HasFocus, that exists in other programming languages such as Visual Basic and Visual C++, is not an attribute of wx.Window in wx.Python.
But if the problem is to know whether the TextCtrl has focus, it is possible to handle the events wx.EVT_SET:FOCUS and wx.EVT_LOST_FOCUS, enabling and disabling a variable like self.textHAS_FOCUS.
I think you are correct, but there's the method FindFocus()...it may or may not work for the OP's needs
Mike
···
2009/1/7 Udo Müller <wxpyu-1208@mueller-udo.de <mailto:wxpyu-1208@mueller-udo.de>>
Hi
Am 07.01.2009 um 17:38 schrieb Danny Shevitz <shevitz@lanl.gov
<mailto:shevitz@lanl.gov>>:
Howdy,
I did my best to search the archives for this question, but
came up blank, so...
I am using the Enthought\TraitsGui framework which uses
wxPython. My problem
is that I have a keybinding for the delete key in a tree
control that deletes
the selected node.
Unfortunately, due to the way TGUI works if I have a right panel
TextEditor (TextCtrl) open and am editing and use the delete
key, the keybinding
is executed first so that the node is deleted instead of the
correct character
in the TextCtrl being deleted.
My solution to this is in the keybinding code to determine if
the textctrl
is actively being edited. Is there a method to determine if a
TextCtrl is
actively being edited? I know the standard way would be to
respond to an event,
but I can't do this. I need to programatically interrogate the
control, not
passively respond
I am a noob but i think you should check if the tree HasFocus()
and if it has delete the node.
Udo
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
<mailto:wxpython-users@lists.wxwidgets.org>
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
------------------------------------------------------------------------
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
thanks for all the posts so far. I can't use events because I don't have
access to the class source code.
In addition, I need to know whether the editor is open (the cursor is in the
text), not whether the control has focus. These are different things. I want
to know if the control is being actively edited, not just if it has the focus.
thanks,
Danny
It is still not clear to me what means for a wxTextCtrl to be active. But if it is of any use for you wxTextCtrl.GetInsertionPoint()
will return the actual position of the cursor. If the result is different from zero, the user is doing something with the control.
As to events and their use, have a look for Bind() at the following address
http://www.wxpython.org/docs/api/wx.EvtHandler-class.html#Bind
or in
http://wiki.wxpython.org/self.Bind%20vs.%20self.button.Bind
and/or google “wxPython Bind”.
···
2009/1/8 Danny Shevitz shevitz@lanl.gov
thanks for all the posts so far. I can’t use events because I don’t have
access to the class source code.
In addition, I need to know whether the editor is open (the cursor is in the
text), not whether the control has focus. These are different things. I want
to know if the control is being actively edited, not just if it has the focus.
thanks,
Danny
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users