View Issue Details

IDProjectCategoryView StatusLast Update
0026019LazarusOtherpublic2015-11-22 16:10
ReporterLionAssigned ToOndrej Pokorny 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformIntel PentiumOSWindowsOS Version7
Product Version1.2.0Product Build44303 
Target VersionFixed in Version1.6 
Summary0026019: QuestionDlg dialog does not work correctly!
DescriptionIf 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 Reproduceif QuestionDlg('Message', 'Here is the text ...', mtInformation, [mrYes, 'Yes', mrOk, 'Ok'], 0) = mrYes then Label1.Caption := 'Hi!';
Tagsdialog boxes
Fixed in Revision50369
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • ScreenshotBug.PNG (40,841 bytes)
    ScreenshotBug.PNG (40,841 bytes)
  • 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
    
    gtk2-qdlg.diff (947 bytes)
  • 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;
    
    qt-qdlg.diff (937 bytes)
  • 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
    
    win32-qdlg.diff (664 bytes)

Relationships

related to 0028988 closedOndrej Pokorny QuestionDlg doesn't always return mrCancel when Escape key is pressed 

Activities

Lion

2014-04-14 12:21

reporter  

ScreenshotBug.PNG (40,841 bytes)
ScreenshotBug.PNG (40,841 bytes)

Lion

2014-04-28 14:45

reporter   ~0074641

Push

Bart Broersma

2014-04-30 15:54

developer   ~0074689

Last edited: 2014-04-30 16:17

View 2 revisions

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.

Bart Broersma

2014-10-04 15:25

developer  

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
gtk2-qdlg.diff (947 bytes)

Bart Broersma

2014-10-04 15:25

developer  

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;
qt-qdlg.diff (937 bytes)

Bart Broersma

2014-10-04 15:28

developer  

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
win32-qdlg.diff (664 bytes)

Bart Broersma

2014-10-04 15:29

developer   ~0077986

Attached possible fixes (so that it behaves like MessageDlg) for win32, GTK2, QT.

Ondrej Pokorny

2015-11-10 22:22

developer   ~0087228

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.)

Ondrej Pokorny

2015-11-17 16:31

developer   ~0087359

Last edited: 2015-11-17 16:32

View 2 revisions

Since there were no objections and nobody made any other proposal how to solve it, I am resolving it with my patch :)

Issue History

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