View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0026019 | Lazarus | Other | public | 2014-04-14 12:21 | 2015-11-22 16:10 |
Reporter | Lion | Assigned To | Ondrej Pokorny | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | Intel Pentium | OS | Windows | OS Version | 7 |
Product Version | 1.2.0 | Product Build | 44303 | ||
Target Version | Fixed in Version | 1.6 | |||
Summary | 0026019: QuestionDlg dialog does not work correctly! | ||||
Description | If you close (Top, right, with the closing button.) the QuestionDlg, the query is true. if QuestionDlg('Message', 'Here is the text ...', mtInformation, [mrYes, 'Yes', mrOk, 'Ok'], 0) = mrYes then Label1.Caption := 'Hi!'; Unso it is not true if you close the the QuestionDlg with closing button (top, right). if QuestionDlg('Message', 'Here is the text ...', mtInformation, [mrYes, 'Yes', mrOk, 'Ok'], 0) = mrOk then Label1.Caption := 'Hi!'; | ||||
Steps To Reproduce | if QuestionDlg('Message', 'Here is the text ...', mtInformation, [mrYes, 'Yes', mrOk, 'Ok'], 0) = mrYes then Label1.Caption := 'Hi!'; | ||||
Tags | dialog boxes | ||||
Fixed in Revision | 50369 | ||||
LazTarget | - | ||||
Widgetset | Win32/Win64 | ||||
Attached Files |
|
related to | 0028988 | closed | Ondrej Pokorny | QuestionDlg doesn't always return mrCancel when Escape key is pressed |
|
|
|
Push |
|
This is by design. One of the buttons gets Cancel = True. This is determined by the buttons you use. However it is rather inconsistent with MessageDlg behaviour. I will discuss this with the other devels to see if and how to fix it. |
|
gtk2-qdlg.diff (947 bytes)
Index: lcl/interfaces/gtk2/gtk2lclintf.inc =================================================================== --- lcl/interfaces/gtk2/gtk2lclintf.inc (revision 46316) +++ lcl/interfaces/gtk2/gtk2lclintf.inc (working copy) @@ -987,7 +987,7 @@ Btns := GTK_BUTTONS_NONE; DefaultId := 0; - CancelId := -1; + CancelId := idButtonCancel; //-1; for X := 0 to Buttons.Count - 1 do begin DlgBtn:=Buttons[X]; @@ -997,10 +997,11 @@ if (Buttons.CancelButton=DlgBtn) or ((Buttons.CancelButton=nil) and DlgBtn.Cancel) then begin - CancelID := X; - ADialogResult := DlgBtn.ModalResult; + //CancelID := X; + //Always respond with mrCancel to VK_ESCAPE, so ignore CancelButton. + //This is consistent with PromptDlg behaviour + ADialogResult := mrCancel; end; - if (ADialogResult = mrNone) and (Buttons[X].ModalResult in [mrCancel, mrAbort, mrIgnore, mrNo, mrNoToAll]) then |
|
qt-qdlg.diff (937 bytes)
Index: lcl/interfaces/qt/qtlclintf.inc =================================================================== --- lcl/interfaces/qt/qtlclintf.inc (revision 46316) +++ lcl/interfaces/qt/qtlclintf.inc (working copy) @@ -176,7 +176,9 @@ if (BtnID >= Low(IdButtonToQtStandardButton)) and (BtnID <= High(IdButtonToQtStandardButton)) and (IdButtonToQtStandardButton[BtnID] <> QMessageBoxNoButton) then - QtMessageBox.AddButton(Caption, IdButtonToQtStandardButton[BtnID], ModalResult, Default, Cancel) + //Setting AEscapeBtn parameter to False ensures the result will be mrCancel allways when + //user presses VK_ESCAPE, this is consistent with PropmtUser behaviour + QtMessageBox.AddButton(Caption, IdButtonToQtStandardButton[BtnID], ModalResult, Default, False {was: Cancel}) else QtMessageBox.AddButton(Caption, ModalResult, Default, Cancel); end; |
|
win32-qdlg.diff (664 bytes)
Index: lcl/interfaces/win32/win32lclintf.inc =================================================================== --- lcl/interfaces/win32/win32lclintf.inc (revision 46391) +++ lcl/interfaces/win32/win32lclintf.inc (working copy) @@ -387,8 +387,11 @@ try Result := IDCANCEL; TaskDialogIndirect(@TaskConfig, @Result, nil, nil); + //To be consistent with PromptUser, do not convert IDCANCEL value + { if (Result = IDCANCEL) and Assigned(Buttons.CancelButton) then Result := Buttons.CancelButton.ModalResult; + } finally RestoreApplicationState(State); for i := 0 to TaskConfig.cButtons - 1 do |
|
Attached possible fixes (so that it behaves like MessageDlg) for win32, GTK2, QT. |
|
Bart, thanks for finding the old issue report! I missed it - yes, it's a duplicate. ----- Now to the patches: I checked yours and mine and I think that my patch is better because in my patch the widgetset code still takes CancelButton into account. If somebody wants to create his own QuestionDlg with a custom CancelButton, he can still do it with my patch. No chance to do it with your patch because your patch ignores the CancelButton on the widgetset-level. Do you agree? (+ for consistency, CancelButton support should be added to Carbon as well.) |
|
Since there were no objections and nobody made any other proposal how to solve it, I am resolving it with my patch :) |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-04-14 12:21 | Lion | New Issue | |
2014-04-14 12:21 | Lion | File Added: ScreenshotBug.PNG | |
2014-04-14 12:41 | Lion | Tag Attached: dialog boxes | |
2014-04-28 14:45 | Lion | Note Added: 0074641 | |
2014-04-30 15:54 | Bart Broersma | Note Added: 0074689 | |
2014-04-30 16:17 | Bart Broersma | Note Edited: 0074689 | View Revisions |
2014-04-30 16:18 | Bart Broersma | Assigned To | => Bart Broersma |
2014-04-30 16:18 | Bart Broersma | Status | new => assigned |
2014-10-04 15:25 | Bart Broersma | File Added: gtk2-qdlg.diff | |
2014-10-04 15:25 | Bart Broersma | File Added: qt-qdlg.diff | |
2014-10-04 15:28 | Bart Broersma | File Added: win32-qdlg.diff | |
2014-10-04 15:29 | Bart Broersma | Note Added: 0077986 | |
2015-11-10 21:38 | Bart Broersma | Relationship added | related to 0028988 |
2015-11-10 22:22 | Ondrej Pokorny | Note Added: 0087228 | |
2015-11-17 16:28 | Ondrej Pokorny | Assigned To | Bart Broersma => Ondrej Pokorny |
2015-11-17 16:31 | Ondrej Pokorny | Fixed in Revision | => 50369 |
2015-11-17 16:31 | Ondrej Pokorny | LazTarget | => - |
2015-11-17 16:31 | Ondrej Pokorny | Note Added: 0087359 | |
2015-11-17 16:31 | Ondrej Pokorny | Status | assigned => resolved |
2015-11-17 16:31 | Ondrej Pokorny | Fixed in Version | => 1.6 |
2015-11-17 16:31 | Ondrej Pokorny | Resolution | open => fixed |
2015-11-17 16:32 | Ondrej Pokorny | Note Edited: 0087359 | View Revisions |