mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 02:19:32 +02:00
implement return key clicks default button; escape key clicks cancel button
git-svn-id: trunk@5623 -
This commit is contained in:
parent
db5790517d
commit
9dbc1ae5d7
@ -64,7 +64,8 @@ type
|
|||||||
FDefault: Boolean;
|
FDefault: Boolean;
|
||||||
FModalResult: TModalResult;
|
FModalResult: TModalResult;
|
||||||
FShortCut: TLMShortcut;
|
FShortCut: TLMShortcut;
|
||||||
Procedure SetDefault(Value : Boolean);
|
procedure SetCancel(NewCancel: boolean);
|
||||||
|
procedure SetDefault(Value : Boolean);
|
||||||
procedure WMDefaultClicked(var Message: TLMessage); message LM_CLICKED;
|
procedure WMDefaultClicked(var Message: TLMessage); message LM_CLICKED;
|
||||||
protected
|
protected
|
||||||
procedure Click; override;
|
procedure Click; override;
|
||||||
@ -85,7 +86,7 @@ type
|
|||||||
property Default : Boolean read FDefault write SetDefault default false;
|
property Default : Boolean read FDefault write SetDefault default false;
|
||||||
property Enabled;
|
property Enabled;
|
||||||
property ModalResult: TModalResult read FModalResult write FModalResult default mrNone;
|
property ModalResult: TModalResult read FModalResult write FModalResult default mrNone;
|
||||||
property Cancel: Boolean read FCancel write FCancel default False;
|
property Cancel: Boolean read FCancel write SetCancel default false;
|
||||||
property Caption;
|
property Caption;
|
||||||
property Font;
|
property Font;
|
||||||
property TabStop default true;
|
property TabStop default true;
|
||||||
@ -329,6 +330,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.68 2004/06/30 11:07:20 micha
|
||||||
|
implement return key clicks default button; escape key clicks cancel button
|
||||||
|
|
||||||
Revision 1.67 2004/05/22 14:35:32 mattias
|
Revision 1.67 2004/05/22 14:35:32 mattias
|
||||||
fixed button return key
|
fixed button return key
|
||||||
|
|
||||||
|
@ -1784,6 +1784,7 @@ uses
|
|||||||
WSControls, // Widgetset uses circle is allowed
|
WSControls, // Widgetset uses circle is allowed
|
||||||
|
|
||||||
Forms, // the circle can't be broken without breaking Delphi compatibility
|
Forms, // the circle can't be broken without breaking Delphi compatibility
|
||||||
|
Buttons, // needed for clicking default and cancel buttons
|
||||||
Math; // Math is in RTL and only a few functions are used.
|
Math; // Math is in RTL and only a few functions are used.
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -2323,6 +2324,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.217 2004/06/30 11:07:20 micha
|
||||||
|
implement return key clicks default button; escape key clicks cancel button
|
||||||
|
|
||||||
Revision 1.216 2004/06/29 10:23:00 micha
|
Revision 1.216 2004/06/29 10:23:00 micha
|
||||||
fix cnkeydown to check wm_getdlgcode result
|
fix cnkeydown to check wm_getdlgcode result
|
||||||
fix win32 intf to also send wm_keydown of cn_keydown wasn't processed
|
fix win32 intf to also send wm_keydown of cn_keydown wasn't processed
|
||||||
|
@ -336,6 +336,8 @@ type
|
|||||||
private
|
private
|
||||||
FActive: Boolean;
|
FActive: Boolean;
|
||||||
FActiveControl: TWinControl;
|
FActiveControl: TWinControl;
|
||||||
|
FDefaultButton: TControl;
|
||||||
|
FEscapeButton: TControl;
|
||||||
FDesigner: TIDesigner;
|
FDesigner: TIDesigner;
|
||||||
FDummyTextHeight: Longint;
|
FDummyTextHeight: Longint;
|
||||||
FFormState: TFormState;
|
FFormState: TFormState;
|
||||||
@ -371,6 +373,8 @@ type
|
|||||||
procedure SetActive(AValue: Boolean);
|
procedure SetActive(AValue: Boolean);
|
||||||
procedure SetActiveControl(AWinControl: TWinControl);
|
procedure SetActiveControl(AWinControl: TWinControl);
|
||||||
procedure SetFormBorderStyle(NewStyle: TFormBorderStyle);
|
procedure SetFormBorderStyle(NewStyle: TFormBorderStyle);
|
||||||
|
procedure SetEscapeButton(NewButton: TControl);
|
||||||
|
procedure SetDefaultButton(NewButton: TControl);
|
||||||
procedure SetDesigner(Value : TIDesigner);
|
procedure SetDesigner(Value : TIDesigner);
|
||||||
procedure SetFormStyle(Value : TFormStyle);
|
procedure SetFormStyle(Value : TFormStyle);
|
||||||
procedure SetIcon(AValue: TIcon);
|
procedure SetIcon(AValue: TIcon);
|
||||||
@ -446,8 +450,10 @@ type
|
|||||||
property ActiveControl: TWinControl read FActiveControl write SetActiveControl;
|
property ActiveControl: TWinControl read FActiveControl write SetActiveControl;
|
||||||
property BorderStyle: TFormBorderStyle
|
property BorderStyle: TFormBorderStyle
|
||||||
read FFormBorderStyle write SetFormBorderStyle default bsSizeable;
|
read FFormBorderStyle write SetFormBorderStyle default bsSizeable;
|
||||||
|
property EscapeButton: TControl read FEscapeButton write SetEscapeButton;
|
||||||
property Caption stored IsForm;
|
property Caption stored IsForm;
|
||||||
property Color default clBtnFace;
|
property Color default clBtnFace;
|
||||||
|
property DefaultButton: TControl read FDefaultButton write SetDefaultButton;
|
||||||
property Designer: TIDesigner read FDesigner write SetDesigner;
|
property Designer: TIDesigner read FDesigner write SetDesigner;
|
||||||
property FormState: TFormState read FFormState;
|
property FormState: TFormState read FFormState;
|
||||||
property FormStyle: TFormStyle read FFormStyle write SetFormStyle
|
property FormStyle: TFormStyle read FFormStyle write SetFormStyle
|
||||||
@ -1052,7 +1058,7 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
WSForms, // Widgetset uses circle is allowed
|
WSForms, // Widgetset uses circle is allowed
|
||||||
|
Buttons,
|
||||||
Math;
|
Math;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
@ -86,15 +86,40 @@ begin
|
|||||||
DoSendBtnDefault;
|
DoSendBtnDefault;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TButton.SetCancel
|
||||||
|
Params: NewCancel - new cancel value
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TButton.SetCancel(NewCancel: boolean);
|
||||||
|
var
|
||||||
|
Form: TCustomForm;
|
||||||
|
begin
|
||||||
|
if FCancel = NewCancel then Exit;
|
||||||
|
FCancel := NewCancel;
|
||||||
|
Form := GetParentForm(Self);
|
||||||
|
if NewCancel then
|
||||||
|
Form.EscapeButton := Self
|
||||||
|
else
|
||||||
|
Form.EscapeButton := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TButton.SetDefault
|
Method: TButton.SetDefault
|
||||||
Params: Value
|
Params: Value
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TButton.SetDefault(Value : Boolean);
|
procedure TButton.SetDefault(Value : Boolean);
|
||||||
|
var
|
||||||
|
Form: TCustomForm;
|
||||||
begin
|
begin
|
||||||
if FDefault = Value then Exit;
|
if FDefault = Value then Exit;
|
||||||
FDefault := Value;
|
FDefault := Value;
|
||||||
|
Form := GetParentForm(Self);
|
||||||
|
if Value then
|
||||||
|
Form.DefaultButton := Self
|
||||||
|
else
|
||||||
|
Form.DefaultButton := nil;
|
||||||
DoSendBtnDefault;
|
DoSendBtnDefault;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
@ -157,6 +182,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.28 2004/06/30 11:07:20 micha
|
||||||
|
implement return key clicks default button; escape key clicks cancel button
|
||||||
|
|
||||||
Revision 1.27 2004/06/29 14:38:28 micha
|
Revision 1.27 2004/06/29 14:38:28 micha
|
||||||
fix default button notification win32 intf
|
fix default button notification win32 intf
|
||||||
|
|
||||||
|
@ -192,6 +192,41 @@ begin
|
|||||||
Result:=FKeyPreview=true;
|
Result:=FKeyPreview=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomForm.SetEscapeButton(NewButton: TControl);
|
||||||
|
var
|
||||||
|
lButton: TControl;
|
||||||
|
begin
|
||||||
|
if NewButton <> FEscapeButton then
|
||||||
|
begin
|
||||||
|
// prevent inf. recursion problems
|
||||||
|
lButton := FEscapeButton;
|
||||||
|
FEscapeButton := nil;
|
||||||
|
// TODO: TControl -> TButton so we don't have to check type ?
|
||||||
|
if lButton <> nil then
|
||||||
|
(lButton as TButton).Cancel := false;
|
||||||
|
FEscapeButton := NewButton;
|
||||||
|
if NewButton <> nil then
|
||||||
|
(NewButton as TButton).Cancel := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomForm.SetDefaultButton(NewButton: TControl);
|
||||||
|
var
|
||||||
|
lButton: TControl;
|
||||||
|
begin
|
||||||
|
if NewButton <> FDefaultButton then
|
||||||
|
begin
|
||||||
|
// prevent inf. recursion problems
|
||||||
|
lButton := FDefaultButton;
|
||||||
|
FDefaultButton := nil;
|
||||||
|
if lButton <> nil then
|
||||||
|
(lButton as TButton).Default := false;
|
||||||
|
FDefaultButton := NewButton;
|
||||||
|
if NewButton <> nil then
|
||||||
|
(NewButton as TButton).Default := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomForm.SetIcon
|
Method: TCustomForm.SetIcon
|
||||||
Params: the new icon
|
Params: the new icon
|
||||||
@ -1607,6 +1642,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.141 2004/06/30 11:07:20 micha
|
||||||
|
implement return key clicks default button; escape key clicks cancel button
|
||||||
|
|
||||||
Revision 1.140 2004/05/22 11:06:27 mattias
|
Revision 1.140 2004/05/22 11:06:27 mattias
|
||||||
fixed grids SetBorderStyle
|
fixed grids SetBorderStyle
|
||||||
|
|
||||||
|
@ -2063,12 +2063,31 @@ end;
|
|||||||
{ TWinControl ControlKeyUp }
|
{ TWinControl ControlKeyUp }
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
procedure TWinControl.ControlKeyDown(var Key: Word; Shift: TShiftState);
|
procedure TWinControl.ControlKeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
Form: TCustomForm;
|
||||||
begin
|
begin
|
||||||
// handle tab keys
|
// handle tab keys
|
||||||
if (Key=VK_Tab) and ((Shift+[ssShift])=[ssShift]) and Focused then begin
|
if (Key=VK_Tab) and ((Shift+[ssShift])=[ssShift]) and Focused then begin
|
||||||
Key:=VK_UNKNOWN;
|
Key:=VK_UNKNOWN;
|
||||||
PerformTab(not (ssShift in Shift));
|
PerformTab(not (ssShift in Shift));
|
||||||
end;
|
end;
|
||||||
|
if (Shift = []) and ((Key = VK_RETURN) or (Key = VK_ESCAPE)) then
|
||||||
|
begin
|
||||||
|
Form := GetParentForm(Self);
|
||||||
|
case Key of
|
||||||
|
VK_RETURN:
|
||||||
|
begin
|
||||||
|
if Form.DefaultButton <> nil then
|
||||||
|
(Form.DefaultButton as TButton).Click;
|
||||||
|
end;
|
||||||
|
|
||||||
|
VK_ESCAPE:
|
||||||
|
begin
|
||||||
|
if Form.EscapeButton <> nil then
|
||||||
|
(Form.EscapeButton as TButton).Click;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
@ -3706,6 +3725,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.245 2004/06/30 11:07:20 micha
|
||||||
|
implement return key clicks default button; escape key clicks cancel button
|
||||||
|
|
||||||
Revision 1.244 2004/06/29 10:23:00 micha
|
Revision 1.244 2004/06/29 10:23:00 micha
|
||||||
fix cnkeydown to check wm_getdlgcode result
|
fix cnkeydown to check wm_getdlgcode result
|
||||||
fix win32 intf to also send wm_keydown of cn_keydown wasn't processed
|
fix win32 intf to also send wm_keydown of cn_keydown wasn't processed
|
||||||
|
Loading…
Reference in New Issue
Block a user