wxRichTextStyleOrganiserDialog returns wxID_OK when closed with Escape key
|Reported by:||ikamakj||Owned by:|
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.