Tabbing across hidden panels

I have multiple panels in the same sizer and am using the trick of hiding all but one at any time so I can switch between different views.

I noticed today that I can tab across onto the hidden panels and press buttons with space which is confusing for the user and is unwanted behaviour

I thought about how to solve this and all I could think of was disabling all the tabbable controls when the panel hides, and enabling when they’re shown which won’t be particularly nice to implement or maintain

Are there any cleaner ways of stopping this behaviour?

If all the controls in each panel are in their own sizers, i.e. your
structure is {TopSizer{Panel{PanelSizer{Controls...}}..}} then you could
try calling Disable on the sizer for all panels other than the one
shown, something like:

def ViewPanel(self, PanelId):
   for(Panel in self.Panels):
       Show = (Panel.Id == PanelId)
       Panel.Show(Show)
       Panel.PanelSizer.Enable(Show)

If that doesn't do the trick then you might be better off binding a tab
event handler to the last control on each panel that sets the focus to
the first control on that panel, or if your last controls are common to
all the panels you could set the tab handler on the last of these to
take you to the first control in the visible panel. If you do this
don't forget shif-tab handling as well.

Gadget/Steve

···

On 15/09/2012 10:28 PM, Paul Wiseman wrote:

I have multiple panels in the same sizer and am using the trick of
hiding all but one at any time so I can switch between different views.

I noticed today that I can tab across onto the hidden panels and press
buttons with space which is confusing for the user and is unwanted
behaviour

I thought about how to solve this and all I could think of was
disabling all the tabbable controls when the panel hides, and enabling
when they're shown which won't be particularly nice to implement or
maintain

Are there any cleaner ways of stopping this behaviour?
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I have multiple panels in the same sizer and am using the trick of
hiding all but one at any time so I can switch between different views.

I noticed today that I can tab across onto the hidden panels and press
buttons with space which is confusing for the user and is unwanted
behaviour

I thought about how to solve this and all I could think of was
disabling all the tabbable controls when the panel hides, and enabling
when they're shown which won't be particularly nice to implement or
maintain

Are there any cleaner ways of stopping this behaviour?

Please create a ticket about this at trac.wxwidgets.org. I think that the tab traversal code should be checking whether the panel is shown before giving it the opportunity to take the focus (and passing it on to its first child.)

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

If all the controls in each panel are in their own sizers, i.e. your
structure is {TopSizer{Panel{PanelSizer{Controls...}}..}} then you could
try calling Disable on the sizer for all panels other than the one
shown, something like:

def ViewPanel(self, PanelId):
    for(Panel in self.Panels):
        Show = (Panel.Id == PanelId)
        Panel.Show(Show)
        Panel.PanelSizer.Enable(Show)

Close, but no cookie. Sizers don't have an Enable method, but calling Enable on the panel should enable/disable all the widgets on the panel.

···

On 9/15/12 11:03 PM, Gadget/Steve wrote:

On 15/09/2012 10:28 PM, Paul Wiseman wrote:

--
Robin Dunn
Software Craftsman