View Issue Details

IDProjectCategoryView StatusLast Update
0028988LazarusLCLpublic2015-11-17 16:33
ReporterOndrej PokornyAssigned ToOndrej Pokorny 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5 (SVN)Product Buildtrunk 
Target VersionFixed in Version1.6 
Summary0028988: QuestionDlg doesn't always return mrCancel when Escape key is pressed
DescriptionIf you press the Escape key or click on dialog close button in QuestionDlg, there is different behavior in different WS:

- Win32, Gtk2, Qt: ModalResult of one of the buttons is returned (in this order: mrCancel, mrAbort, mrNo, mrIgnore, mrNoToAll, mrYes, mrOk, mrRetry, mrAll, mrYesToAll). Yes even mrYes is possible!!!
- Carbon: always mrCancel

Wanted: always mrCancel
Steps To ReproduceSee the attached example project for a self-contained example. Hit "Escape" or close the dialog with the close button. Wanted result is "mrCancel".

---
Real-life example:
1.) start building the IDE (or a big app) in Lazarus and run "compile" again.
2.) The dialog "The IDE is still building" appears.
3.) Press "Escape".
4.) Building will be aborted !!! Instead, building should continue !!!

---
(Obviously, the above steps-to-reproduce show wrong behavior only on Win32/Gtk2/Qt. Carbon behaves the way I want it even without the patch.)
Additional InformationPossible patch attached. Please review and comment if you have objections.

I tested:
Win32, Gtk2, Qt, Carbon -> the new behavior is the consistent now. If the user hits "Escape" or closes the dialog with the close button, mrCancel is always returned.
TagsNo tags attached.
Fixed in Revision50369
LazTarget-
Widgetset
Attached Files
  • QuestionDlg.zip (1,232 bytes)
  • questiondlg-1.patch (2,281 bytes)
    Index: lcl/include/promptdialog.inc
    ===================================================================
    --- lcl/include/promptdialog.inc	(revision 50264)
    +++ lcl/include/promptdialog.inc	(working copy)
    @@ -924,7 +924,6 @@
         end;
         if DialogButtons.DefaultButton = nil then
           DialogButtons.DefaultButton := DialogButtons.FindButton([mrYes, mrOk, mrYesToAll, mrAll, mrRetry, mrCancel, mrNo, mrNoToAll, mrAbort, mrIgnore]);
    -    DialogButtons.CancelButton := DialogButtons.FindButton([mrCancel, mrAbort, mrNo, mrIgnore, mrNoToAll, mrYes, mrOk, mrRetry, mrAll, mrYesToAll]);
         Result := WidgetSet.AskUser(aCaption, ConvertLineEndings(aMsg),
           DialogIds[DlgType], DialogButtons, HelpCtx);
       finally
    Index: lcl/interfaces/gtk2/gtk2lclintf.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2lclintf.inc	(revision 50264)
    +++ lcl/interfaces/gtk2/gtk2lclintf.inc	(working copy)
    @@ -975,7 +975,7 @@
     begin
       Result := mrNone;
       ReleaseCapture;
    -  ADialogResult := mrNone;
    +  ADialogResult := mrCancel;
       case DialogType of
         idDialogWarning: GtkDialogType := GTK_MESSAGE_WARNING;
         idDialogError: GtkDialogType := GTK_MESSAGE_ERROR;
    @@ -1000,11 +1000,6 @@
           CancelID := X;
           ADialogResult := DlgBtn.ModalResult;
         end;
    -
    -    if (ADialogResult = mrNone) and
    -      (Buttons[X].ModalResult in [mrCancel, mrAbort, mrIgnore, mrNo, mrNoToAll])
    -    then
    -      ADialogResult := Buttons[X].ModalResult;
       end;
     
     
    Index: lcl/interfaces/win32/win32lclintf.inc
    ===================================================================
    --- lcl/interfaces/win32/win32lclintf.inc	(revision 50264)
    +++ lcl/interfaces/win32/win32lclintf.inc	(working copy)
    @@ -391,8 +391,13 @@
         try
           Result := IDCANCEL;
           TaskDialogIndirect(@TaskConfig, @Result, nil, nil);
    -      if (Result = IDCANCEL) and Assigned(Buttons.CancelButton) then
    -        Result := Buttons.CancelButton.ModalResult;
    +      if (Result = IDCANCEL) then
    +      begin
    +        if Assigned(Buttons.CancelButton) then
    +          Result := Buttons.CancelButton.ModalResult
    +        else
    +          Result := mrCancel;
    +      end;
         finally
           RestoreApplicationState(State);
           for i := 0 to TaskConfig.cButtons - 1 do
    
    questiondlg-1.patch (2,281 bytes)

Relationships

related to 0026019 resolvedOndrej Pokorny QuestionDlg dialog does not work correctly! 

Activities

Ondrej Pokorny

2015-11-10 07:44

reporter  

QuestionDlg.zip (1,232 bytes)

Ondrej Pokorny

2015-11-10 07:46

reporter  

questiondlg-1.patch (2,281 bytes)
Index: lcl/include/promptdialog.inc
===================================================================
--- lcl/include/promptdialog.inc	(revision 50264)
+++ lcl/include/promptdialog.inc	(working copy)
@@ -924,7 +924,6 @@
     end;
     if DialogButtons.DefaultButton = nil then
       DialogButtons.DefaultButton := DialogButtons.FindButton([mrYes, mrOk, mrYesToAll, mrAll, mrRetry, mrCancel, mrNo, mrNoToAll, mrAbort, mrIgnore]);
-    DialogButtons.CancelButton := DialogButtons.FindButton([mrCancel, mrAbort, mrNo, mrIgnore, mrNoToAll, mrYes, mrOk, mrRetry, mrAll, mrYesToAll]);
     Result := WidgetSet.AskUser(aCaption, ConvertLineEndings(aMsg),
       DialogIds[DlgType], DialogButtons, HelpCtx);
   finally
Index: lcl/interfaces/gtk2/gtk2lclintf.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2lclintf.inc	(revision 50264)
+++ lcl/interfaces/gtk2/gtk2lclintf.inc	(working copy)
@@ -975,7 +975,7 @@
 begin
   Result := mrNone;
   ReleaseCapture;
-  ADialogResult := mrNone;
+  ADialogResult := mrCancel;
   case DialogType of
     idDialogWarning: GtkDialogType := GTK_MESSAGE_WARNING;
     idDialogError: GtkDialogType := GTK_MESSAGE_ERROR;
@@ -1000,11 +1000,6 @@
       CancelID := X;
       ADialogResult := DlgBtn.ModalResult;
     end;
-
-    if (ADialogResult = mrNone) and
-      (Buttons[X].ModalResult in [mrCancel, mrAbort, mrIgnore, mrNo, mrNoToAll])
-    then
-      ADialogResult := Buttons[X].ModalResult;
   end;
 
 
Index: lcl/interfaces/win32/win32lclintf.inc
===================================================================
--- lcl/interfaces/win32/win32lclintf.inc	(revision 50264)
+++ lcl/interfaces/win32/win32lclintf.inc	(working copy)
@@ -391,8 +391,13 @@
     try
       Result := IDCANCEL;
       TaskDialogIndirect(@TaskConfig, @Result, nil, nil);
-      if (Result = IDCANCEL) and Assigned(Buttons.CancelButton) then
-        Result := Buttons.CancelButton.ModalResult;
+      if (Result = IDCANCEL) then
+      begin
+        if Assigned(Buttons.CancelButton) then
+          Result := Buttons.CancelButton.ModalResult
+        else
+          Result := mrCancel;
+      end;
     finally
       RestoreApplicationState(State);
       for i := 0 to TaskConfig.cButtons - 1 do
questiondlg-1.patch (2,281 bytes)

Issue History

Date Modified Username Field Change
2015-11-10 07:44 Ondrej Pokorny New Issue
2015-11-10 07:44 Ondrej Pokorny File Added: QuestionDlg.zip
2015-11-10 07:46 Ondrej Pokorny File Added: questiondlg-1.patch
2015-11-10 07:49 Ondrej Pokorny Steps to Reproduce Updated View Revisions
2015-11-10 21:38 Bart Broersma Relationship added related to 0026019
2015-11-17 16:24 Ondrej Pokorny Assigned To => Ondrej Pokorny
2015-11-17 16:24 Ondrej Pokorny Status new => assigned
2015-11-17 16:33 Ondrej Pokorny Fixed in Revision => 50369
2015-11-17 16:33 Ondrej Pokorny Status assigned => resolved
2015-11-17 16:33 Ondrej Pokorny Fixed in Version => 1.6
2015-11-17 16:33 Ondrej Pokorny Resolution open => fixed
2015-11-17 16:33 Ondrej Pokorny Status resolved => closed