Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#16185 closed defect (fixed)

CreateXXXButtonSizer functions with just wxCLOSE flag: Close button won't close dialog

Reported by: snowleopard2 Owned by: VZ
Priority: normal Milestone: 3.1.0
Component: GUI-all Version: dev-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

If you call:

CreateSeparatedSizer(wxCLOSE)

to add a Close button to a dialog, then at runtime clicking the Close button will not close the dialog and hitting ESC on the keyboard won't do anything either. However, using wxCANCEL will work.

Explicitly setting either wxCLOSE or wxCLOSE (depending on which is present) as the escape ID fixes it, patch attached.

Attachments (1)

update.diff download (466 bytes) - added by snowleopard2 6 months ago.
Patch for fix

Download all attachments as: .zip

Change History (5)

Changed 6 months ago by snowleopard2

Patch for fix

comment:1 Changed 6 months ago by vadz

  • Milestone set to 3.1.0
  • Status changed from new to confirmed

I wonder if we shouldn't make wxID_CLOSE the affirmative ID instead. Setting it as escape ID really doesn't make sense because this button is supposed to accept the changes, not cancel them.

Does anybody see any problems with this, i.e. the following patch:

  • src/common/dlgcmn.cpp

    diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp
    index 4b23e83..49d4f1e 100644
    a b wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) 
    370370        SetAffirmativeId(wxID_OK); 
    371371    else if (flags & wxYES) 
    372372        SetAffirmativeId(wxID_YES); 
     373    else if (flags & wxCLOSE) 
     374        SetAffirmativeId(wxID_CLOSE); 
    373375 
    374376    sizer->Realize(); 
    375377 

?

comment:2 Changed 6 months ago by snowleopard2

Looks good to me, thanks.

comment:3 Changed 6 months ago by VZ

  • Owner set to VZ
  • Resolution set to fixed
  • Status changed from confirmed to closed

In 76421:

Make "Close" button affirmative ID in standard dialog button sizer.

This allows to use the Escape key to close a dialog with the "Close" button
only.

Closes #16185.

comment:4 Changed 6 months ago by VZ

In 76422:

Make "Close" button affirmative ID in standard dialog button sizer.

This allows to use the Escape key to close a dialog with the "Close" button
only.

Closes #16185.

Note: See TracTickets for help on using tickets.