Hot Door CORE Forum
FloatingDialog issues between Mac and Windows? - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: General discussion (http://hotdoorcore.com/forum/forumdisplay.php?fid=3)
+--- Thread: FloatingDialog issues between Mac and Windows? (/showthread.php?tid=186)



FloatingDialog issues between Mac and Windows? - Rick Johnson - 10-09-2018

I've noticed some differences in the behavior of floating dialogs between Mac and Windows, and would like to pass along what I've found. Windows opens a floating dialog from whatever callback contains the .show(), calls blur and focus when expected, then closes the window with either close, OK, or Cancel callbacks. The Mac, by contrast, also calls Focus each time a window is open and Blur just before it closes for any reason.


RE: FloatingDialog issues between Mac and Windows? - TerryMulhern - 02-28-2019

Quote:I've noticed some differences in the behavior of floating dialogs between Mac and Windows, and would like to pass along what I've found. Windows opens a floating dialog from whatever callback contains the .show(), calls blur and focus when expected, then closes the window with either close, OK, or Cancel homework help callbacks. The Mac, by contrast, also calls Focus each time a window is open and Blur just before it closes for any reason.

Hi,
Could you please share the source code for FloatingDialog?
Thanks.


RE: FloatingDialog issues between Mac and Windows? - Rick Johnson - 03-02-2019

Hi Terry,

I'm not sure how much of the code you're looking for, so I hope this covers it. The CORE Tool sample project has a good example of how to build a dialog. In this case, you just declare it as a FloatingDialog rather than ModalDialog, and in postStartup() add callbacks for focus, blur, and close events.

Code:
    this->latDlg = hdi::core::FloatingDialog("Latitude Settings", hdi::core::Size(modalWidth, modalHeight));
    this-> latDlg.setBlurCallback(HDI_CORE_CALLBACK(mapProj::Plugin, this, blurDlgCB));
    this-> latDlg.setCloseCallback(HDI_CORE_CALLBACK(mapProj::Plugin, this, closeDlgCB));
    this-> latDlg.setFocusCallback(HDI_CORE_CALLBACK(mapProj::Plugin, this, focusDlgCB));

For the OK button, I define it this way so it's automatically a default button and closes the window:

Code:
    OKbtn.setStyle(hdi::core::Button::DefaultStyle);

I set the Cancel button's behavior similarly:

Code:
    cancelBtn.setStyle(hdi::core::Button::CancelStyle);

In the callbacks for these events and the OK and cancel buttons, I added compiler directives to account for differences in Mac and Windows.

Code:
void mapProj::Plugin::OKbtnCB(){
#ifdef WIN_ENV
    this->blurDlgCB();
#endif
//    your code here
}

void mapProj::Plugin::CancelBtnCB(){
//    Mac automatically calls blurDlg first
#ifdef WIN_ENV
    this->blurDlgCB();
#endif
//    your code here
}

void mapProj::Plugin::focusDlgCB(){
//    called when the dialog has been re-selected by the user
//    your code here
}

void mapProj::Plugin::blurDlgCB(){
//    called when the dialog is deactivated, e.g., user fiddles with art in the document
//    your code here
}

void mapProj::Plugin::closeDlgCB(){
//    Mac automatically calls blurDlg first
#ifdef WIN_ENV
        this->blurDlgCB();
#endif
//    your code here
}

Then, wherever in your code you show this dialog, just add a compiler directive for Windows to handle the focus event:

Code:
    this->latDlg.show();
#ifdef WIN_ENV
    this->focusDlgCB();
#endif

From here you shouldn't have to be concerned anymore about platform differences. :-)