View Issue Details

IDProjectCategoryView StatusLast Update
0032509LazarusLCLpublic2017-10-05 00:45
ReporterDenis Kozlov Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.9 (SVN) 
Summary0032509: Escape key triggers a disabled cancel button
DescriptionEscape key triggers the Click event of a disabled cancel button, which is wrong.

This is also unlike the Return key handling, which first checks if the default button is actually enabled and visible before triggering the Click event.

Also checked with Delphi 2010, both Escape and Return keys do not trigger actions if buttons are disabled or not visible.

Attached patch fixes this issue. Example project attached.
Tagspatch
Fixed in Revisionr55975
LazTarget-
Widgetset
Attached Files

Activities

Denis Kozlov

2017-10-04 12:19

reporter  

application-escape-key-cancel-action.inc.patch (1,182 bytes)   
Index: lcl/include/application.inc
===================================================================
--- lcl/include/application.inc	(revision 55964)
+++ lcl/include/application.inc	(working copy)
@@ -2110,6 +2110,7 @@
   Shift: TShiftState);
 var
   Form: TCustomForm;
+  lCancelControl: TControl;
 begin
   if (Shift = []) and (Key = VK_ESCAPE) and
      (AControl.Perform(CM_WANTSPECIALKEY, Key, 0) = 0) and
@@ -2117,11 +2118,19 @@
      (anoEscapeForCancelControl in Navigation) then
   begin
     Form := GetParentForm(AControl);
-    if Assigned(Form) and Assigned(Form.CancelControl) then
+    if Assigned(Form) then
     begin
-      //debugln('TApplication.ControlKeyUp VK_ESCAPE ', Acontrol.Name);
-      Form.CancelControl.ExecuteCancelAction;
-      Key := VK_UNKNOWN;
+      lCancelControl := Form.CancelControl;
+      if Assigned(lCancelControl)
+        and lCancelControl.Enabled and lCancelControl.Visible then
+      begin
+        //debugln('TApplication.ControlKeyUp VK_ESCAPE ', Acontrol.Name);
+        try
+          lCancelControl.ExecuteCancelAction;
+        finally
+          Key := VK_UNKNOWN;
+        end;
+      end;
     end;
   end;
 end;

Denis Kozlov

2017-10-04 12:19

reporter  

Denis Kozlov

2017-10-04 12:20

reporter   ~0103186

Please apply to 1.8 branch if not too late.

Juha Manninen

2017-10-05 00:45

developer   ~0103195

Applied, thanks.
I will mark it for merging to 1.8 branch soon if no problems are found.

Issue History

Date Modified Username Field Change
2017-10-04 12:19 Denis Kozlov New Issue
2017-10-04 12:19 Denis Kozlov File Added: application-escape-key-cancel-action.inc.patch
2017-10-04 12:19 Denis Kozlov File Added: AppEscapeKeyCancelAction.zip
2017-10-04 12:20 Denis Kozlov Tag Attached: patch
2017-10-04 12:20 Denis Kozlov Note Added: 0103186
2017-10-05 00:36 Juha Manninen Assigned To => Juha Manninen
2017-10-05 00:36 Juha Manninen Status new => assigned
2017-10-05 00:45 Juha Manninen Fixed in Revision => r55975
2017-10-05 00:45 Juha Manninen LazTarget => -
2017-10-05 00:45 Juha Manninen Note Added: 0103195
2017-10-05 00:45 Juha Manninen Status assigned => resolved
2017-10-05 00:45 Juha Manninen Resolution open => fixed