FIX: Hotkey labels from Keys show up in toolbar hover info tags (fixes #1044)

(cherry picked from commit 03483a1044)
This commit is contained in:
Alexander Koblov 2023-07-30 13:39:21 +03:00
commit f9fbdedb82
4 changed files with 38 additions and 3 deletions

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
Toolbar panel class
Copyright (C) 2006-2019 Alexander Koblov (alexx2000@mail.ru)
Copyright (C) 2006-2023 Alexander Koblov (alexx2000@mail.ru)
contributors:
2012 Przemyslaw Nagay (cobines@gmail.com)
@ -33,7 +33,7 @@ interface
uses
Classes, SysUtils, LResources, Forms, Controls, ComCtrls,
Graphics, Dialogs, ExtCtrls, Buttons, FileUtil, Menus,
DCXmlConfig, KASToolItems, LCLVersion;
DCXmlConfig, KASToolItems, LCLVersion, LMessages;
type
TOnToolButtonClick = procedure (Sender: TObject) of object;
@ -64,6 +64,7 @@ type
function DrawGlyph(ACanvas: TCanvas; const AClient: TRect; const AOffset: TPoint;
AState: TButtonState; ATransparent: Boolean; BiDiFlags: Longint): TRect; override;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
procedure CMHintShow(var Message: TLMessage); message CM_HINTSHOW;
public
constructor Create(AOwner: TComponent; Item: TKASToolItem); reintroduce;
destructor Destroy; override;
@ -1089,6 +1090,17 @@ begin
end;
end;
procedure TKASToolButton.CMHintShow(var Message: TLMessage);
begin
if (ActionLink <> nil) and FToolItem.ActionHint then
begin
inherited CMHintShow(Message);
end
else begin
DoOnShowHint(TCMHintShow(Message).HintInfo);
end;
end;
constructor TKASToolButton.Create(AOwner: TComponent; Item: TKASToolItem);
begin
inherited Create(AOwner);

View file

@ -62,6 +62,7 @@ type
FAction: TBasicAction;
property ToolOwner: IToolOwner read FToolOwner;
public
function ActionHint: Boolean; virtual;
procedure Assign(OtherItem: TKASToolItem); virtual;
function CheckExecute(ToolItemID: String): Boolean; virtual;
function Clone: TKASToolItem; virtual; abstract;
@ -94,6 +95,8 @@ type
{ TKASNormalItem }
TKASNormalItem = class(TKASToolItem)
private
FShortcutsHint: Boolean;
strict private
FID: String; // Unique identificator of the button
function GetID: String;
@ -105,6 +108,7 @@ type
Icon: String;
Text: String;
Hint: String;
function ActionHint: Boolean; override;
procedure Assign(OtherItem: TKASToolItem); override;
function CheckExecute(ToolItemID: String): Boolean; override;
function Clone: TKASToolItem; override;
@ -183,6 +187,11 @@ uses
{ TKASToolItem }
function TKASToolItem.ActionHint: Boolean;
begin
Result := True;
end;
procedure TKASToolItem.Assign(OtherItem: TKASToolItem);
begin
FUserData := OtherItem.FUserData;
@ -481,8 +490,10 @@ function TKASNormalItem.GetShortcutsHint: String;
begin
if Assigned(FToolOwner) then
Result := FToolOwner.GetToolItemShortcutsHint(Self)
else
else begin
Result := '';
end;
FShortcutsHint := (Length(Result) > 0);
end;
procedure TKASNormalItem.Load(Config: TXmlConfig; Node: TXmlNode; Loader: TKASToolBarLoader);
@ -525,6 +536,11 @@ begin
Config.AddValueDef(Node, 'Text', Text, '');
end;
function TKASNormalItem.ActionHint: Boolean;
begin
Result := not FShortcutsHint;
end;
{ TKASToolBarItems }
constructor TKASToolBarItems.Create;

View file

@ -593,6 +593,7 @@ var
i: Integer;
shortcut: TShortCut;
begin
if Length(hotkey.Params) > 0 then Exit;
shortcut := TextToShortCutEx(hotkey.Shortcuts[0]);
for i := 0 to FActionLists.Count - 1 do
begin

View file

@ -45,6 +45,7 @@ type
constructor Create(AFormCommands: IFormCommands); reintroduce;
procedure Assign(OtherItem: TKASToolItem); override;
function Clone: TKASToolItem; override;
function ActionHint: Boolean; override;
function ConfigNodeName: String; override;
procedure Load(Config: TXmlConfig; Node: TXmlNode; Loader: TKASToolBarLoader); override;
procedure SaveContents(Config: TXmlConfig; Node: TXmlNode); override;
@ -155,6 +156,11 @@ begin
Result.Assign(Self);
end;
function TKASCommandItem.ActionHint: Boolean;
begin
Result:= (inherited ActionHint) and (Length(Params) = 0);
end;
function TKASCommandItem.ConfigNodeName: String;
begin
Result := CommandItemConfigNode;