wxDirPickerCtrl window unable to get focus, MAC OSX 10.6

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
tedzini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Tue Apr 20, 2010 2:30 pm

wxDirPickerCtrl window unable to get focus, MAC OSX 10.6

Post by tedzini » Thu Jan 13, 2011 4:04 am

Greetings,

I built carbon 32bit on MAC OSX 10.6.5. The widgets samples compiles and runs fine (as well as other samples to my interest). I ported a program which worked well on WinXP, Win7 via Xcode 3.2, but I have been experiencing several issues with the MAC port.

A class, "TM_TruckSimConfig", which inherits wxDialog utilizes wxDirPickerCtrl and wxFilePickerCtrl widgets. When the browse button is clicked the file (or dir) browser window appears behind the dialog. However, I'm unable to acquire focus of the browser window *until* I close the dialog box!
This is rather odd behavior that I have been unable to track down.

Would anyone care to shed some light as to what I should be looking for etc.? Here is an example of the code I use in the class:

Code: Select all

m_LapscoreFilePathCtrl = new wxDirPickerCtrl( itemCollapsiblePane15->GetPane(), ID_DIRPICKERCTRL_LAPSCORE, wxEmptyString, _("Select an existing path to store the lapscore file"), 
									wxDefaultPosition, wxDefaultSize, (wxDIRP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST) );
<snip>

where m_LapscoreFilePathCtrl is a member of the class. Code such as this is contained within a 'CreateControls' method, as shown in a "Create" method below:

<snip>
bool TM_TruckSimConfig::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin TM_TruckSimConfig member initialisation
    m_RoadDBSelectionCtrl = NULL;
    m_TimeLimitCtrl = NULL;
    m_RecordCtrl = NULL;
    m_LapscoreCtrl = NULL;
    m_RecordFilePathCtrl = NULL;
    m_RecordFileNameCtrl = NULL;
    m_LapscoreFilePathCtrl = NULL;
    m_LapscoreFileNameCtrl = NULL;
    m_UserNameCtrl = NULL;
    m_DateStampCtrl = NULL;
    m_StudentDLLPathCtrl = NULL;
////@end TM_TruckSimConfig member initialisation

////@begin TM_TruckSimConfig creation
    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
    wxDialog::Create( parent, id, caption, pos, size, style );

    CreateControls();
    SetIcon(GetIconResource(wxT("../icons_images/abadr_Highway.xpm")));
    if (GetSizer())
    {
        GetSizer()->SetSizeHints(this);
    }
    Centre();
////@end TM_TruckSimConfig creation
    return TRUE;
}

many thanks!

Ted

EDIT by Auria: Please use code tags

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Thu Jan 13, 2011 6:58 pm

Hi,

wouldn't they both happen to be modal? (your dialog and the file picker one). I think wxOSX (v 2.8 at least) has issues when there is more than 1 modal dialog at a time.
"Keyboard not detected. Press F1 to continue"
-- Windows

tedzini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Tue Apr 20, 2010 2:30 pm

Post by tedzini » Sat Jan 15, 2011 2:40 am

Auria -- indeed you are correct and I am using 2.9.1 carbon 32bit build on OSX 10.6.5.

This is really bad news; Would you (or anyone who glances at this thread) have any suggestions how to emulate this behavior with ->Show() non-modal wxDialogs ?

I'm scanning through some of the samples, but I can't seem to find one that explains this very well.

thanks,
t

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sat Jan 15, 2011 7:25 pm

For the gory details, see the last post at http://old.nabble.com/Modeless-from-Mod ... 64564.html

But really, I would recommend to rethink your application so that there is only one dialog at a time, dialogs within dialogs are annoying; maybe the first one can be non-modal, or maybe before showing the second dialog just close the first one
"Keyboard not detected. Press F1 to continue"
-- Windows

tedzini
Knows some wx things
Knows some wx things
Posts: 34
Joined: Tue Apr 20, 2010 2:30 pm

Post by tedzini » Sun Jan 16, 2011 4:30 pm

thanks for the very interesting post/article.

Really, in this instance (no pun intended ;-)), multiple dialogs are most desirable because, the secondary modal dialogs are the file/directory pickers (via the "browse" button). It naturally follows the context of the configuration dialog(s) in question here.

After reading this, one idea I have is to pass in a pointer to a method function of the parent wxFrame that will be called on a non-modal, wxDialog close window event handler; The parent method function would then be used to obtain the flags, etc., from the dialog and take appropriate actions. I would like to therefore override/event.skip() wxID_CANCEL and wxID_OK button event handling in the dialog to set my own CANCEL/ID_OK flags in the inherited, non-model wxDialog class. If you can understand where I'm going with this, does this seem reasonable? I presume I will be able to handle those button events just like any other button events, no?

again, thanks very much for your help/edification with MAC OSX porting.

-t

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sun Jan 16, 2011 7:47 pm

Perhaps the first dialog can simply have the float on parent style instead of being modal.
"Keyboard not detected. Press F1 to continue"
-- Windows

Post Reply