mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 05:58:06 +02:00
IDE: Execute a shortcut command only when it is enabled.
This commit is contained in:
parent
8c248da41d
commit
b6a4282835
@ -570,6 +570,7 @@ type
|
||||
FOnUpdateProc: TNotifyProcedure;
|
||||
FUsers: TIDESpecialCommands;
|
||||
|
||||
function GetEnabled: Boolean;
|
||||
function GetUser(Index: Integer): TIDESpecialCommand;
|
||||
function GetUserCount: Integer;
|
||||
procedure SetOnExecute(const aOnExecute: TNotifyEvent);
|
||||
@ -609,7 +610,7 @@ type
|
||||
procedure DoOnUpdate; overload;
|
||||
procedure DoOnUpdate(Sender: TObject); overload;
|
||||
public
|
||||
property Enabled: Boolean write SetEnabled; // set Enabled of all "Users" TIDESpecialCommand, use Users to read
|
||||
property Enabled: Boolean read GetEnabled write SetEnabled;
|
||||
property Caption: string write SetCaption; // set Caption of all "Users" TIDESpecialCommand, use Users to read
|
||||
property Hint: string write SetHint; // set Hint of all "Users" TIDESpecialCommand, use Users to read
|
||||
// don't add Visible property here - it is not generic. Tool buttons should never be hidden programmatically
|
||||
@ -1298,6 +1299,14 @@ begin
|
||||
Result := FUsers[Index];
|
||||
end;
|
||||
|
||||
function TIDECommand.GetEnabled: Boolean;
|
||||
begin
|
||||
if FUsers.Count > 0 then
|
||||
Result := FUsers[0].Enabled
|
||||
else
|
||||
Result := True; // A command without SpecialCommands is enabled.
|
||||
end;
|
||||
|
||||
function TIDECommand.GetUserCount: Integer;
|
||||
begin
|
||||
Result := FUsers.Count;
|
||||
|
@ -3506,7 +3506,7 @@ var
|
||||
IDECmd: TIDECommand;
|
||||
s: String;
|
||||
begin
|
||||
//debugln('TMainIDE.OnProcessIDECommand ',dbgs(Command));
|
||||
//DebugLn('TMainIDE.OnProcessIDECommand START ',dbgs(Command));
|
||||
Handled:=true;
|
||||
|
||||
case Command of
|
||||
@ -3548,7 +3548,6 @@ begin
|
||||
if ToolStatus = itNone then begin
|
||||
if DebugBoss.InitDebugger([difInitForAttach]) then begin
|
||||
s := GetPidForAttach;
|
||||
|
||||
if s <> '' then begin
|
||||
ToolStatus := itDebugger;
|
||||
DebugBoss.Attach(s);
|
||||
@ -3635,7 +3634,7 @@ begin
|
||||
// custom commands
|
||||
IDECmd:=IDECommandList.FindIDECommand(Command);
|
||||
//DebugLn('TMainIDE.OnProcessIDECommand Command=',dbgs(Command),' ',dbgs(IDECmd));
|
||||
if IDECmd<>nil then
|
||||
if Assigned(IDECmd) and IDECmd.Enabled then
|
||||
Handled:=IDECmd.Execute(IDECmd);
|
||||
end;
|
||||
//DebugLn('TMainIDE.OnProcessIDECommand Handled=',dbgs(Handled),' Command=',dbgs(Command));
|
||||
|
Loading…
Reference in New Issue
Block a user