Notebook windows lose focus?

Hi,

After upgrading from wxPython 2.4.2.4 to 2.5.1.5, I noticed something peculiar. I have an editor that uses a Notebook with a StyledTextCtrl on each page. With 2.4.2.4, these editor windows automatically had focus when you changed pages (or created a new page, etc). In other words, I could go to other tabs and the editor in that tab would have a blinking cursor, ready for editing.

This is no longer the case with 2.5.1.5. After changing tabs, or opening a new one, I now have to click on the editor to make it gain focus. A small but annoying difference.

I tried adding an EVT_NOTEBOOK_PAGE_CHANGED event to set the focus manually after the page has been changed. This doesn't work though. The event is called, but the SetFocus() seems to have no effect, or is somehow undone.

Losing focus also happens if I click on *the same* tab as I'm currently on.

Disclaimer: I'm not using "straight" wxPython, but Wax, a layer on top of wxPython. (http://zephyrfalcon.org/labs/) However, the Wax code doesn't do anything special, and used to work fine in 2.4.2.4.

What I'd like to know is, is this a known problem, or should I inspect my code more critically?

Thanks,

···

--
Hans (hans@zephyrfalcon.org)
http://zephyrfalcon.org/

P.S. I'm on Windows 2000.

···

--
Hans (hans@zephyrfalcon.org)
http://zephyrfalcon.org/

Hans Nowak wrote:

Hi,

After upgrading from wxPython 2.4.2.4 to 2.5.1.5, I noticed something peculiar. I have an editor that uses a Notebook with a StyledTextCtrl on each page. With 2.4.2.4, these editor windows automatically had focus when you changed pages (or created a new page, etc). In other words, I could go to other tabs and the editor in that tab would have a blinking cursor, ready for editing.

This is no longer the case with 2.5.1.5. After changing tabs, or opening a new one, I now have to click on the editor to make it gain focus. A small but annoying difference.

The notebook is now allowed to receive the focus, so you can change tabs
with the keyboard.

I tried adding an EVT_NOTEBOOK_PAGE_CHANGED event to set the focus manually after the page has been changed. This doesn't work though. The event is called, but the SetFocus() seems to have no effect, or is somehow undone.

Try doing it with wx.CallAfter so it happens after the page changed
event has finished processing

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

I tried adding an EVT_NOTEBOOK_PAGE_CHANGED event to set the focus manually after the page has been changed. This doesn't work though. The event is called, but the SetFocus() seems to have no effect, or is somehow undone.

Try doing it with wx.CallAfter so it happens after the page changed
event has finished processing

Thanks, that works. Well, except for one case: if you click on the current tab. Is there a way to catch that? I'm guessing the "page changed" event is not called in that case. It's not really important, but if there's a simple way to catch this as well, I'd like to learn about it.

Thanks,

···

--
Hans (hans@zephyrfalcon.org)
http://zephyrfalcon.org/

Hans Nowak wrote:

Robin Dunn wrote:

I tried adding an EVT_NOTEBOOK_PAGE_CHANGED event to set the focus manually after the page has been changed. This doesn't work though. The event is called, but the SetFocus() seems to have no effect, or is somehow undone.

Try doing it with wx.CallAfter so it happens after the page changed
event has finished processing

Thanks, that works. Well, except for one case: if you click on the current tab. Is there a way to catch that? I'm guessing the "page changed" event is not called in that case. It's not really important, but if there's a simple way to catch this as well, I'd like to learn about it.

You can get mouse events for the notebook and in 2.5 there is a HitTest
method to find out what tab was clicked.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!