X button in upper right corner of modal dialog

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
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

X button in upper right corner of modal dialog

Post by rsb »

Hello,

I'm using wxWidgets version 3.1.0 on RHEL8 Linux.
// Output of uname -a
Linux Freeman 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Tue Jan 14 15:50:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

After invoking a modal dialog, the X button in the upper right corner is visible but pressing it does nothing.
Windows works fine and call the OnClose event.

Any idea what is wrong or missing?

Thanks.

We have Cancel and Close event handlers.

BEGIN_EVENT_TABLE(itiManageGroupsDialog,itiBaseDialog)
EVT_BUTTON(wxID_OK,itiManageGroupsDialog::OnExecute)
EVT_BUTTON(wxID_CANCEL,itiManageGroupsDialog::OnCancel)
EVT_CLOSE(itiManageGroupsDialog::OnClose)
EVT_INIT_DIALOG(itiManageGroupsDialog::OnInit)
END_EVENT_TABLE()

void itiManageGroupsDialog::OnCancel(wxCommandEvent &event)
{
wxLogWarning("OnCancel") ;
EndModal(wxID_CANCEL) ;
event.Skip();
}

void itiManageGroupsDialog::OnClose(wxCloseEvent &event)
{
wxLogWarning("OnCancel") ;
EndModal(wxID_CANCEL) ;
event.Skip();
}
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: X button in upper right corner of modal dialog

Post by ONEEYEMAN »

Hi,
Couple of comments:
1. You should supply the "code" tags around the code you post on the forum. There is an appropriate button at the top of the text control.
2. You don't have to supply "event.Skip()" when you handle the wxCommandEvent. Those events are not system events, but rather user-defined.
And so this call doesn't do anything. You should, however, use it when handling the system-generated events (keyboard, mouse, focus).
3. Can you compile and run the dialogs sample and see if it has the same behavior you observe.
4. What version of GTK+ the program is compiled against?

Finally, it would be great if you can try with the Git master and see if this was a bug that already been fixed.

Thank you.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: X button in upper right corner of modal dialog

Post by DavidHart »

Hi,

On debian buster, in a gtk+3 wx3.1.1 build (and also in git head), the 'modeless' dialog (Ctrl-Sh-Z) of the 'dialogs' sample successfully catches wxID_CLOSE. So you can merge your code into that until something breaks.

Regards,

David
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: X button in upper right corner of modal dialog

Post by ONEEYEMAN »

David,
I think the OP is asking about the MODAL dialog.

Thank you.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: X button in upper right corner of modal dialog

Post by DavidHart »

I think the OP is asking about the MODAL dialog.
Yes, but it's the modeless dialog in that sample that catches wxID_CLOSE.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: X button in upper right corner of modal dialog

Post by rsb »

Not really sure how to determine the GTK+ version.

Tried this: rpm -qa | grep -i gtk

Came back with this: gtk2-2.24.32-4.el8.x86_64

-----

Yes, the X button in our Modeless dialogs work.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: X button in upper right corner of modal dialog

Post by DavidHart »

Not really sure how to determine the GTK+ version.
Doing Ctrl-Alt-Middleclick over any wx program will show a dialog that shows the wx and (for linux) gtk version.

Here's a quick-and-very-dirty diff to the dialogs sample that turns the modeless dialog modal. For me, it still catches the 'X' click, both in gtk2 and gtk3 builds.
dialogs.diff
(701 Bytes) Downloaded 80 times
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: X button in upper right corner of modal dialog

Post by rsb »

From the diff, it looks like your just replacing ShowModal with Show but we really don't want to do this.

I didn't see anything on GitHub that helped. There were references to wxID_CLOSE but none of the cases referenced this issue
that I could find.

Thanks.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: X button in upper right corner of modal dialog

Post by DavidHart »

No, vice versa:

Code: Select all

-        m_dialog->Show(true);
+        m_dialog->ShowModal();
Post Reply