Tab traversal

26 views
Skip to first unread message

jon bird

unread,
Mar 20, 2021, 1:52:51 PMMar 20
to wx-u...@googlegroups.com
Hi,

Am having an issue getting tab traversal to work (wxWidgets 3.1.3 on
Windows). It's a top level wxFrame window, the style includes
wxTAB_TRAVERSAL however when hitting tab in a text control nothing
happens (well the PC goes 'ding' but that probably doesn't count).

I've tried handling this myself based on
https://wiki.wxwidgets.org/WxComboBox (I have combo boxes in this
configuration so figured I'd need to do it anyway). Hence I have
something like:

void PlayoutExpress::DbExpress::EvtKeyDown(wxKeyEvent& event)
{
if (event.GetKeyCode() == WXK_TAB)
NavigateIn(wxNavigationKeyEvent::IsForward);
else
event.Skip();
}

The event gets hit ok - the odd thing is I can step through the code
inside NavigateIn (it doesn't seem to do that much):

bool wxWindowBase::DoNavigateIn(int flags)
{
#ifdef wxHAS_NATIVE_TAB_TRAVERSAL
// native code doesn't process our wxNavigationKeyEvents anyhow
wxUnusedVar(flags);
return false;
#else // !wxHAS_NATIVE_TAB_TRAVERSAL
wxNavigationKeyEvent eventNav;
wxWindow *focused = FindFocus();
eventNav.SetCurrentFocus(focused);
eventNav.SetEventObject(focused);
eventNav.SetFlags(flags);
return GetEventHandler()->ProcessEvent(eventNav);
#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
}

and it successfully calls into 'wxEvtHandler::ProcessEvent'. In there I
find a bunch of checks for seeing if the event can be handled but
ultimately in drops out having done nothing.

...

// No handler found anywhere, bail out.
return false;
}

The implication from the docs is that this should just work without me
needing to do anything special.

Any help appreciated.

Rgs,


Jon.


--
--
== jon bird - software engineer
== <reply to address _may_ be invalid, real mail below>
== <reduce rsi, stop using the shift key>
== posted as: news 'at' onasticksoftware 'dot' co 'dot' uk

Igor Korot

unread,
Mar 20, 2021, 2:16:12 PMMar 20
to wx-u...@googlegroups.com
Hi, Jon,

On Sat, Mar 20, 2021 at 12:52 PM jon bird <ne...@onasticksoftware.co.uk> wrote:
>
> Hi,
>
> Am having an issue getting tab traversal to work (wxWidgets 3.1.3 on
> Windows). It's a top level wxFrame window, the style includes
> wxTAB_TRAVERSAL however when hitting tab in a text control nothing
> happens (well the PC goes 'ding' but that probably doesn't count).

Does it help if you use wxPanel as a parent?
I know this should work but for testing...

Thank you.
> --
> Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
> To unsubscribe, send email to wx-users+u...@googlegroups.com
> or visit http://groups.google.com/group/wx-users
> ---
> You received this message because you are subscribed to the Google Groups "wx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/20210320175231.00006586%40onasticksoftware.co.uk.

jon bird

unread,
Mar 21, 2021, 12:59:22 PMMar 21
to wx-u...@googlegroups.com
Hi Igor,

On Sat, 20 Mar 2021 13:15:50 -0500
Igor Korot <ikor...@gmail.com> wrote:

> Hi, Jon,
>
> On Sat, Mar 20, 2021 at 12:52 PM jon bird
> <ne...@onasticksoftware.co.uk> wrote:
> >
> > Hi,
> >
> > Am having an issue getting tab traversal to work (wxWidgets 3.1.3 on
> > Windows). It's a top level wxFrame window, the style includes
> > wxTAB_TRAVERSAL however when hitting tab in a text control nothing
> > happens (well the PC goes 'ding' but that probably doesn't count).
>
> Does it help if you use wxPanel as a parent?
> I know this should work but for testing...
>
> Thank you.
>

It does indeed seem to work as expected when things are sat inside
panels. Trying it with another app I've written, it even seems to work
across multiple panels which are all within the same wxFrame. Strange
behaviour, is this by design then?

Vadim Zeitlin

unread,
Mar 21, 2021, 1:11:05 PMMar 21
to wx-u...@googlegroups.com
On Sun, 21 Mar 2021 16:59:14 +0000 jon bird wrote:

jb> It does indeed seem to work as expected when things are sat inside
jb> panels. Trying it with another app I've written, it even seems to work
jb> across multiple panels which are all within the same wxFrame. Strange
jb> behaviour, is this by design then?

Yes. You need to have a wxControlContainer implementing TAB navigation
somewhere and the simplest way to ensure there is one is to use a wxPanel.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages