Page 1 of 1

How to prevent a wxButton from gaining the focus by pressing the TAB from the keyboard?

Posted: Tue Aug 27, 2019 9:58 pm
by tomay3000
Hello,
As asked in the title, how to do so, or simply remove this wxButton from the tab navigation order at all, and allow the focus to be set only by a mouse click.

TIA.

Re: How to prevent a wxButton from gaining the focus by pressing the TAB from the keyboard?

Posted: Tue Aug 27, 2019 11:24 pm
by Manolo
Use mybutton->SetCanFocus(false) See https://docs.wxwidgets.org/trunk/classw ... 66f1b7f3d8

Re: How to prevent a wxButton from gaining the focus by pressing the TAB from the keyboard?

Posted: Wed Aug 28, 2019 12:40 am
by tomay3000
Unfortunately, it didn't worked under Windows 7 :(

Re: How to prevent a wxButton from gaining the focus by pressing the TAB from the keyboard?

Posted: Wed Aug 28, 2019 11:17 am
by doublemax
The cleanest version would be to subclass wxButton, override wxWindow::AcceptsFocusFromKeyboard() and return false there.
https://docs.wxwidgets.org/trunk/classw ... c6aa8301b8