[wxPython-users] Focus behavior change from 2.6 to 2.7?
Saketh
saketh.bhamidipati at gmail.com
Sat Dec 2 13:02:39 PST 2006
On 12/1/06, Robin Dunn <robin at alldunn.com> wrote:
>
> Saketh wrote:
>
> >
> > I have hacked together a small runnable sample which contains the
> > problem. Hit 'Tab' with the focus on the TreeCtrl and the problem
> > manifests itself.
> >
> > I am on Windows XP SP2, wxPython 2.7.2.
>
> It's not a problem. It's doing exactly what you are telling it to do.
>
> > menubar =3D wx.MenuBar()
> > file =3D wx.Menu()
> > tab =3D file.Append(wx.NewId(), 'Insert Tab \tTab', 'Insert a
> tab')
>
> Here you are crating a menu item with Tab as an accelerator...
>
> > menubar.Append(file, '&File')
> > self.SetMenuBar(menubar)
> > self.Bind(wx.EVT_MENU, self.OnTab, tab)
>
> ...and you are binding that menu event to the OnTab method...
>
> > def OnTab(self, e):
> > self.display.WriteText(unicode('\t'))
>
> ...which writes a tab character to the text control. So whenever you
> press Tab while any control within the frame has the focus it is going
> to activate the accelerator and call OnTab.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
> I am aware that my code intercepts the normal functionality of the Tab
key, but in previous versions of wxPython the focus would still change if it
were initially on the TreeCtrl.
Is there any way that I can restore that old functionality? I suppose I
would have to put an if-statement in the OnTab function to check which
widget has focus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200612=
02/ff76171d/attachment.htm
More information about the wxpython-users
mailing list