[OSX] wxButton::SetFocus() not actually setting focus in dialogs

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
tessman
Earned some good credits
Earned some good credits
Posts: 109
Joined: Tue Oct 06, 2009 5:25 pm

[OSX] wxButton::SetFocus() not actually setting focus in dialogs

Post by tessman »

I just wanted to check to make sure this behaviour is consistent for others before delving further into it/reporting it as a bug.

In, for instance, samples/dialogs, if you change the button being SetDefault() in any of the example dialogs, such as MyModalDialog from:

Code: Select all

    m_btnModal->SetFocus();
    m_btnModal->SetDefault();
to

Code: Select all

    m_btnModeless->SetFocus();
    m_btnModeless->SetDefault();
The "Modeless" button gets set as default (coloured blue) but the "Modal" button still has the focus.

It seems to always give focus to the first-added control. If switch the Add() calls around so that the modeless button is added first, it will have the focus. The same seems to apply for any other dialog with a text control added first, etc.: the first-added control gets the focus regardless of SetFocus().
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: [OSX] wxButton::SetFocus() not actually setting focus in dialogs

Post by eranon »

It well works for me on OS X 10.9 Mavericks, changing the code as you shown in the wxWidgets 3.1.0's dialogs sample. The modeless button has focus and appears as being the default.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: [OSX] wxButton::SetFocus() not actually setting focus in dialogs

Post by ONEEYEMAN »

Hi,
Which OSX version did you try?
Which wx version do you use?
What is the minimal version you set when you configured the build?
Do you have access to a different OSX version (for testing)?

Thank you.
tessman
Earned some good credits
Earned some good credits
Posts: 109
Joined: Tue Oct 06, 2009 5:25 pm

Re: [OSX] wxButton::SetFocus() not actually setting focus in dialogs

Post by tessman »

In particular this is on 10.12.6 using a pull from master.

Note that this is with System Preferences > Keyboard > Shortcuts > All controls checked, which you need in order to set keyboard focus to any control (as opposed to just text boxes and lists).
Post Reply