View Issue Details

IDProjectCategoryView StatusLast Update
0021739LazarusLCLpublic2012-04-16 09:12
ReporterDavid JenkinsAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.30.5 (SVN)Product Build 
Target VersionFixed in Version1.1 (SVN) 
Summary0021739: Close button response to [esc] on Carbon
DescriptionIf a button is created and has both the Default and Cancel properties set to true before its parent is assigned (in the button's constructor or creating the button at runtime), the Cancel button can be incorrectly cleared. In that situation, the button's FDefault and FCancel properties are set, but Parent isn't assigned, so it can't update the DefaultControl/CancelControl properties. When it does finally calls TCustomButton.UpdateDefaultCancel, SetDefaultControl calls UpdateRolesForForm, which only returns [ccrfDefault], since CancelControl hasn't been assigned yet.

Suggest fix is to save off FCancel and used stored value

Patch against rev 36681 is attached
TagsNo tags attached.
Fixed in Revision36811
LazTarget-
WidgetsetCarbon
Attached Files
  • buttons.inc.patch (543 bytes)
    --- /Users/djenkins/laz-changes/14827/buttons.inc	2012-04-11 17:19:00.000000000 
    +++ /Users/djenkins/laz-changes/14827/buttons.inc.ss	2012-04-11 17:20:09.000000000 
    @@ -317,13 +317,15 @@
     procedure TCustomButton.UpdateDefaultCancel;
     var
       Form: TCustomForm;
    +  OldCancel: Boolean;
     begin
       Form := GetParentForm(Self);
       if Form <> nil then
       begin
    +    OldCancel := FCancel;
         if FDefault then
           Form.DefaultControl := Self;
    -    if FCancel then
    +    if OldCancel then
           Form.CancelControl := Self;
       end;
       WSSetDefault;
    
    buttons.inc.patch (543 bytes)

Activities

2012-04-13 19:01

 

buttons.inc.patch (543 bytes)
--- /Users/djenkins/laz-changes/14827/buttons.inc	2012-04-11 17:19:00.000000000 
+++ /Users/djenkins/laz-changes/14827/buttons.inc.ss	2012-04-11 17:20:09.000000000 
@@ -317,13 +317,15 @@
 procedure TCustomButton.UpdateDefaultCancel;
 var
   Form: TCustomForm;
+  OldCancel: Boolean;
 begin
   Form := GetParentForm(Self);
   if Form <> nil then
   begin
+    OldCancel := FCancel;
     if FDefault then
       Form.DefaultControl := Self;
-    if FCancel then
+    if OldCancel then
       Form.CancelControl := Self;
   end;
   WSSetDefault;
buttons.inc.patch (543 bytes)

Paul Ishenin

2012-04-16 09:12

manager   ~0058646

I used a bit different approach.

Please test and close if ok.

Issue History

Date Modified Username Field Change
2012-04-13 19:01 David Jenkins New Issue
2012-04-13 19:01 David Jenkins File Added: buttons.inc.patch
2012-04-13 19:01 David Jenkins Widgetset => Carbon
2012-04-16 09:12 Paul Ishenin Fixed in Revision => 36811
2012-04-16 09:12 Paul Ishenin LazTarget => -
2012-04-16 09:12 Paul Ishenin Status new => resolved
2012-04-16 09:12 Paul Ishenin Fixed in Version => 1.1 (SVN)
2012-04-16 09:12 Paul Ishenin Resolution open => fixed
2012-04-16 09:12 Paul Ishenin Assigned To => Paul Ishenin
2012-04-16 09:12 Paul Ishenin Note Added: 0058646