Or maybe a version of the OnDoubleClick method which recalls itself at idle time and then handles string selection, etc.. For example
def OnDoubleClick(self, event, first=True):
if first: # initial event, setup recall
wx.CallAfter(self.OnDoubleClick, event, False)
event.Skip()
else: # recalled at idle time
s = self.GetStringSelection()
....
Disclaimer, the example above and below have not been tested!
/Jean Brouwers
Jean Brouwers wrote:
···
Maybe this will work:
def OnDoubleClick(self. event):
wx.CallAfter(self._GetSelectedString, event)
event.Skip()def _GetSelectedString(self, event):
s = self.GetStringSelection()
....i.e. try to delay getting the selected string until "idle" time.
/Jean Brouwers
Charles Hartman wrote:
I know I should know this! What I'm trying to do is have the user double-click in a TextCtrl, which selects a word, and then retrieve that word. But if, in the subclassed TextCtrl, I do
self.Bind(wx.EVT_RIGHT_DCLICK, OnDoubleClick)
and then
def OnDoubleClick(self, event):
s = self.GetStringSelection()
(or any other call to TextCtrl methods), my OnDoubleClick seems to catch the click too soon: no selection has gotten made. (If I add event.Skip(), of course the word-selection happens, but then it's too late.)I don't think this can be a problem of my forgetting some other method that TextCtrl has or inherits -- it's something I'm forgetting about how messages work.
Any illumination for the dim-witted, much appreciated.
Charles Hartman
"We are working on some minor configuration/security issues which may result in odd behavior over the next 24-48 hours." -- notice on a BBS
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org