Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#15717 closed defect (fixed)

wxRichTextStyleOrganiserDialog returns wxID_OK when closed with Escape key

Reported by: ikamakj Owned by:
Priority: normal Milestone:
Component: wxRichText Version: 2.9.5
Keywords: wxRichTextStyleOrganiserDialog Escape Cc:
Blocked By: Blocking:
Patch: no

Description

When a dialog contains both OK and Cancel buttons, the Escape key should correspond to Cancel. wxRichTextStyleOrganiserDialog does not behave this way when created with wxRICHTEXT_ORGANISER_OK_CANCEL: ShowModal() returns wxID_OK when the user presses Escape.

The reason is that the Cancel and Close buttons have the same ID (wxID_CANCEL), and only one of these is visible. The Close button, although hidden, is the first child with wxID_CANCEL, which makes the logic in SendCloseButtonClickEvent() to think that no enabled Cancel button is present and therefore Escape should correspond to OK. The wxDialogBase logic assumes that no button ID occurs twice.

The problem could be fixed by using wxID_CANCEL for the visible button only, and some arbitrary ID for the hidden button, or by not creating the hidden button at all.
To avoid similar problems elsewhere, maybe EmulateButtonClickIfPresent() should also be corrected so that instead of calling FindWindow() it only finds *visible* buttons having the given ID.

Change History (4)

comment:1 Changed 8 months ago by juliansmart

  • Status changed from new to confirmed

comment:2 Changed 8 months ago by JS

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

(In [75322]) Fixed #15717: wxRichTextStyleOrganiserDialog returns wxID_OK when closed with Escape key (ikamakj)

comment:3 Changed 8 months ago by JS

(In [75323]) Fixed #15717: wxRichTextStyleOrganiserDialog returns wxID_OK when closed with Escape key (ikamakj)

comment:4 Changed 8 months ago by juliansmart

Thanks, now fixed in wxRTC: I won't EmulateButtonClickIfPresent at this point as I think it's a fairly rare case.

Note: See TracTickets for help on using tickets.