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