Skip to content

Commit 070ea3c

Browse files
committed
fix: make some cancel buttons react on Esc key
https://www.heidisql.com/forum.php?t=45320
1 parent 06ab070 commit 070ea3c

5 files changed

Lines changed: 24 additions & 9 deletions

File tree

‎source/exportgrid.lfm‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ object frmExportGrid: TfrmExportGrid
2727
Anchors = [akRight, akBottom]
2828
BorderSpacing.Around = 5
2929
Caption = 'OK'
30+
Default = True
3031
ModalResult = 1
3132
TabOrder = 5
3233
OnClick = btnOKClick
@@ -42,6 +43,7 @@ object frmExportGrid: TfrmExportGrid
4243
Width = 75
4344
Anchors = [akRight, akBottom]
4445
BorderSpacing.Around = 5
46+
Cancel = True
4547
Caption = 'Cancel'
4648
ModalResult = 2
4749
TabOrder = 4

‎source/loaddata.lfm‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ object loaddataform: Tloaddataform
2828
Anchors = [akRight, akBottom]
2929
BorderSpacing.Around = 5
3030
Caption = 'Import!'
31+
Default = True
3132
Enabled = False
3233
ModalResult = 1
3334
TabOrder = 6
@@ -43,6 +44,7 @@ object loaddataform: Tloaddataform
4344
Width = 75
4445
Anchors = [akRight, akBottom]
4546
BorderSpacing.Around = 5
47+
Cancel = True
4648
Caption = 'Cancel'
4749
ModalResult = 2
4850
TabOrder = 7

‎source/tabletools.lfm‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ object frmTableTools: TfrmTableTools
3636
Width = 95
3737
Anchors = [akRight, akBottom]
3838
BorderSpacing.Around = 5
39+
Cancel = True
3940
Caption = 'Close'
4041
ModalResult = 2
4142
TabOrder = 3
@@ -1019,6 +1020,7 @@ object frmTableTools: TfrmTableTools
10191020
Anchors = [akRight, akBottom]
10201021
BorderSpacing.Around = 5
10211022
Caption = 'Execute'
1023+
Default = True
10221024
TabOrder = 2
10231025
OnClick = Execute
10241026
end

‎source/usermanager.lfm‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ object UserManagerForm: TUserManagerForm
728728
ClientWidth = 617
729729
ParentBackground = False
730730
TabOrder = 3
731-
object btnDiscard: TSpeedButton
731+
object btnDiscard: TBitBtn
732732
AnchorSideRight.Control = btnCancel
733733
AnchorSideBottom.Control = pnlBottom
734734
AnchorSideBottom.Side = asrBottom
@@ -739,13 +739,14 @@ object UserManagerForm: TUserManagerForm
739739
Anchors = [akRight, akBottom]
740740
AutoSize = True
741741
BorderSpacing.Left = 5
742-
Constraints.MinWidth = 100
743742
Caption = 'Discard'
743+
Constraints.MinWidth = 100
744744
Images = MainForm.ImageListMain
745745
ImageIndex = 40
746+
TabOrder = 0
746747
OnClick = btnDiscardClick
747748
end
748-
object btnSave: TSpeedButton
749+
object btnSave: TBitBtn
749750
AnchorSideRight.Control = btnDiscard
750751
AnchorSideBottom.Control = pnlBottom
751752
AnchorSideBottom.Side = asrBottom
@@ -755,13 +756,15 @@ object UserManagerForm: TUserManagerForm
755756
Width = 100
756757
Anchors = [akRight, akBottom]
757758
AutoSize = True
758-
Constraints.MinWidth = 100
759759
Caption = 'Save'
760+
Constraints.MinWidth = 100
761+
Default = True
760762
Images = MainForm.ImageListMain
761763
ImageIndex = 10
764+
TabOrder = 1
762765
OnClick = btnSaveClick
763766
end
764-
object btnCancel: TSpeedButton
767+
object btnCancel: TBitBtn
765768
AnchorSideRight.Control = pnlBottom
766769
AnchorSideRight.Side = asrBottom
767770
AnchorSideBottom.Control = pnlBottom
@@ -773,10 +776,12 @@ object UserManagerForm: TUserManagerForm
773776
Anchors = [akRight, akBottom]
774777
AutoSize = True
775778
BorderSpacing.Left = 5
776-
Constraints.MinWidth = 100
779+
Cancel = True
777780
Caption = 'Close'
781+
Constraints.MinWidth = 100
778782
Images = MainForm.ImageListMain
779783
ImageIndex = 26
784+
TabOrder = 2
780785
OnClick = btnCancelClick
781786
end
782787
object lblWarning: TLabel

‎source/usermanager.pas‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ EInputError = class(Exception);
6161
{ TUserManagerForm }
6262

6363
TUserManagerForm = class(TExtForm)
64-
btnCancel: TSpeedButton;
65-
btnSave: TSpeedButton;
64+
btnCancel: TBitBtn;
65+
btnSave: TBitBtn;
6666
comboPlugins: TComboBox;
6767
lblPasswordHint: TLabel;
6868
lblPlugin: TLabel;
@@ -71,7 +71,7 @@ TUserManagerForm = class(TExtForm)
7171
listUsers: TLazVirtualStringTree;
7272
Splitter1: TSplitter;
7373
pnlRight: TPanel;
74-
btnDiscard: TSpeedButton;
74+
btnDiscard: TBitBtn;
7575
lblUsers: TLabel;
7676
ToolBar1: TToolBar;
7777
btnAddUser: TToolButton;
@@ -526,6 +526,10 @@ procedure TUserManagerForm.SetModified(Value: Boolean);
526526
FModified := Value;
527527
btnSave.Enabled := FModified;
528528
btnDiscard.Enabled := FModified and (not FAdded);
529+
btnDiscard.Cancel := False;
530+
btnCancel.Cancel := False;
531+
btnDiscard.Cancel := btnDiscard.Enabled;
532+
btnCancel.Cancel := not btnDiscard.Enabled;
529533
listUsers.Invalidate;
530534
end;
531535

0 commit comments

Comments
 (0)