mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:19:18 +02:00
LCL: fix shortcut handling for TButton and TCheckBox
git-svn-id: trunk@12133 -
This commit is contained in:
parent
7cc294faae
commit
df48056fc0
@ -1710,6 +1710,7 @@ type
|
|||||||
procedure UpdateControlState;
|
procedure UpdateControlState;
|
||||||
procedure UpdateShowing; virtual;
|
procedure UpdateShowing; virtual;
|
||||||
procedure WndProc(var Message: TLMessage); override;
|
procedure WndProc(var Message: TLMessage); override;
|
||||||
|
procedure WSSetText(const AText: String); virtual;
|
||||||
protected
|
protected
|
||||||
// properties which are not supported by all descendents
|
// properties which are not supported by all descendents
|
||||||
property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle default bsNone;
|
property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle default bsNone;
|
||||||
@ -3272,3 +3273,4 @@ finalization
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,24 +260,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomButton.RealSetText(const Value: TCaption);
|
|
||||||
var
|
|
||||||
ParseStr : String;
|
|
||||||
AccelIndex : Longint;
|
|
||||||
OldShortCut: TShortCut;
|
|
||||||
begin
|
|
||||||
inherited RealSetText(Value);
|
|
||||||
If (not HandleAllocated) or (csDesigning in ComponentState) then exit;
|
|
||||||
ParseStr := Value;
|
|
||||||
AccelIndex := DeleteAmpersands(ParseStr);
|
|
||||||
If AccelIndex > -1 then begin
|
|
||||||
OldShortCut := FShortCut;
|
|
||||||
FShortCut := ShortCut(Char2VK(ParseStr[AccelIndex]), [ssCtrl]);
|
|
||||||
TWSButtonClass(WidgetSetClass).SetShortCut(Self, OldShortCut, FShortCut);
|
|
||||||
end;
|
|
||||||
AdjustSize;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCustomButton.ChildClassAllowed(ChildClass: TClass): boolean;
|
function TCustomButton.ChildClassAllowed(ChildClass: TClass): boolean;
|
||||||
begin
|
begin
|
||||||
// no childs
|
// no childs
|
||||||
@ -295,6 +277,29 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomButton.WSSetText(const AText: String);
|
||||||
|
var
|
||||||
|
ParseStr : String;
|
||||||
|
AccelIndex : Longint;
|
||||||
|
OldShortCut: TShortCut;
|
||||||
|
begin
|
||||||
|
if (not HandleAllocated) then
|
||||||
|
exit;
|
||||||
|
if not (csDesigning in ComponentState) then
|
||||||
|
begin
|
||||||
|
ParseStr := AText;
|
||||||
|
AccelIndex := DeleteAmpersands(ParseStr);
|
||||||
|
if AccelIndex > -1 then
|
||||||
|
begin
|
||||||
|
OldShortCut := FShortCut;
|
||||||
|
FShortCut := ShortCut(Char2VK(ParseStr[AccelIndex]), [ssCtrl]);
|
||||||
|
TWSButtonClass(WidgetSetClass).SetShortCut(Self, OldShortCut, FShortCut);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
inherited WSSetText(AText);
|
||||||
|
AdjustSize;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TCustomButton.DoSendBtnDefault;
|
procedure TCustomButton.DoSendBtnDefault;
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -314,3 +319,4 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,6 +147,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomCheckBox.RealSetText(const Value: TCaption);
|
||||||
|
begin
|
||||||
|
if Value = Text then
|
||||||
|
Exit;
|
||||||
|
inherited RealSetText(Value);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomCheckBox.Toggle
|
Method: TCustomCheckBox.Toggle
|
||||||
Params: none
|
Params: none
|
||||||
@ -183,27 +190,26 @@ begin
|
|||||||
inherited Loaded;
|
inherited Loaded;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
procedure TCustomCheckBox.WSSetText(const AText: String);
|
||||||
procedure TCustomCheckBox.RealSetText(const Value: TCaption);
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TCustomCheckBox.RealSetText(const Value: TCaption);
|
|
||||||
var
|
var
|
||||||
ParseStr : String;
|
ParseStr : String;
|
||||||
AccelIndex : Longint;
|
AccelIndex : Longint;
|
||||||
OldKey: word;
|
OldShortCut: TShortCut;
|
||||||
begin
|
begin
|
||||||
if Value=Text then exit;
|
if (not HandleAllocated) then
|
||||||
Inherited RealSetText(Value);
|
exit;
|
||||||
If HandleAllocated and (not (csDesigning in ComponentState)) then begin
|
if not (csDesigning in ComponentState) then
|
||||||
ParseStr := Value;
|
begin
|
||||||
|
ParseStr := AText;
|
||||||
AccelIndex := DeleteAmpersands(ParseStr);
|
AccelIndex := DeleteAmpersands(ParseStr);
|
||||||
If AccelIndex > -1 then begin
|
if AccelIndex > -1 then
|
||||||
OldKey := FShortCut;
|
begin
|
||||||
FShortCut := Char2VK(ParseStr[AccelIndex]);
|
OldShortCut := FShortCut;
|
||||||
TWSCustomCheckBoxClass(WidgetSetClass).SetShortCut(Self, OldKey, FShortCut);
|
FShortCut := ShortCut(Char2VK(ParseStr[AccelIndex]), [ssCtrl]);
|
||||||
|
TWSCustomCheckBoxClass(WidgetSetClass).SetShortCut(Self, OldShortCut, FShortCut);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
InvalidatePreferredSize;
|
inherited WSSetText(AText);
|
||||||
AdjustSize;
|
AdjustSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -3492,6 +3492,12 @@ Begin
|
|||||||
inherited WndProc(Message);
|
inherited WndProc(Message);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TWinControl.WSSetText(const AText: String);
|
||||||
|
begin
|
||||||
|
TWSWinControlClass(WidgetSetClass).SetText(Self, AText);
|
||||||
|
InvalidatePreferredSize;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TWinControl.DoAddDockClient(Client: TControl; const ARect: TRect);
|
procedure TWinControl.DoAddDockClient(Client: TControl; const ARect: TRect);
|
||||||
|
|
||||||
@ -5327,12 +5333,13 @@ begin
|
|||||||
EnableWindow(Handle, Enabled);
|
EnableWindow(Handle, Enabled);
|
||||||
|
|
||||||
// Delay the setting of text until it is completely loaded
|
// Delay the setting of text until it is completely loaded
|
||||||
if not (csLoading in ComponentState) then begin
|
if not (csLoading in ComponentState) then
|
||||||
|
begin
|
||||||
if GetCachedText(CachedText) then
|
if GetCachedText(CachedText) then
|
||||||
TWSWinControlClass(WidgetSetClass).SetText(Self, CachedText);
|
WSSetText(CachedText);
|
||||||
InvalidatePreferredSize;
|
InvalidatePreferredSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if csDesigning in ComponentState
|
if csDesigning in ComponentState
|
||||||
then TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[crDefault])
|
then TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[crDefault])
|
||||||
else TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[Cursor]);
|
else TWSWinControlClass(WidgetSetClass).SetCursor(Self, Screen.Cursors[Cursor]);
|
||||||
@ -5445,7 +5452,7 @@ begin
|
|||||||
if HandleAllocated then begin
|
if HandleAllocated then begin
|
||||||
// Set cached caption
|
// Set cached caption
|
||||||
if GetCachedText(CachedText) then
|
if GetCachedText(CachedText) then
|
||||||
TWSWinControlClass(WidgetSetClass).SetText(Self, CachedText);
|
WSSetText(CachedText);
|
||||||
InvalidatePreferredSize;
|
InvalidatePreferredSize;
|
||||||
|
|
||||||
if wcfColorChanged in FWinControlFlags then begin
|
if wcfColorChanged in FWinControlFlags then begin
|
||||||
@ -6045,10 +6052,9 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TWinControl.RealSetText(const AValue: TCaption);
|
procedure TWinControl.RealSetText(const AValue: TCaption);
|
||||||
begin
|
begin
|
||||||
if HandleAllocated
|
if HandleAllocated and (not (csLoading in ComponentState)) then
|
||||||
and (not (csLoading in ComponentState))
|
begin
|
||||||
then begin
|
WSSetText(AValue);
|
||||||
TWSWinControlClass(WidgetSetClass).SetText(Self, AValue);
|
|
||||||
InvalidatePreferredSize;
|
InvalidatePreferredSize;
|
||||||
end;
|
end;
|
||||||
inherited RealSetText(AValue);
|
inherited RealSetText(AValue);
|
||||||
|
@ -1003,13 +1003,13 @@ type
|
|||||||
procedure ControlKeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure ControlKeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure ControlKeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure ControlKeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure SetParent(AParent: TWinControl); override;
|
procedure SetParent(AParent: TWinControl); override;
|
||||||
procedure RealSetText(const Value: TCaption); override;
|
|
||||||
procedure WSSetDefault;
|
|
||||||
function DialogChar(var Message: TLMKey): boolean; override;
|
function DialogChar(var Message: TLMKey): boolean; override;
|
||||||
function ChildClassAllowed(ChildClass: TClass): boolean; override;
|
function ChildClassAllowed(ChildClass: TClass): boolean; override;
|
||||||
function IsBorderSpacingInnerBorderStored: Boolean; override;
|
function IsBorderSpacingInnerBorderStored: Boolean; override;
|
||||||
property ParentColor default false;
|
property ParentColor default false;
|
||||||
function UseRightToLeftAlignment: Boolean; override;
|
function UseRightToLeftAlignment: Boolean; override;
|
||||||
|
procedure WSSetDefault;
|
||||||
|
procedure WSSetText(const AText: String); override;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
procedure ExecuteDefaultAction; override;
|
procedure ExecuteDefaultAction; override;
|
||||||
@ -1099,6 +1099,7 @@ type
|
|||||||
procedure RealSetText(const Value: TCaption); override;
|
procedure RealSetText(const Value: TCaption); override;
|
||||||
procedure ApplyChanges; virtual;
|
procedure ApplyChanges; virtual;
|
||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
|
procedure WSSetText(const AText: String); override;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
public
|
public
|
||||||
@ -1508,3 +1509,4 @@ end.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user