Browse Source

Fixes Issue #4734 : HotKeys trigger command when control is disabled

pull/4737/head
Giuseppe Lippolis 6 years ago
parent
commit
f1f2df8dd4
  1. 2
      src/Avalonia.Controls/HotkeyManager.cs
  2. 5
      src/Avalonia.Input/ICommandSource.cs

2
src/Avalonia.Controls/HotkeyManager.cs

@ -22,7 +22,7 @@ namespace Avalonia.Controls
private ICommand GetCommand() => CommandSource.Command;
public bool CanExecute(object parameter) => GetCommand()?.CanExecute(parameter) ?? false;
public bool CanExecute(object parameter) => CommandSource.IsEffectivelyEnabled;
public void Execute(object parameter) => GetCommand()?.Execute(parameter);

5
src/Avalonia.Input/ICommandSource.cs

@ -27,5 +27,10 @@ namespace Avalonia.Input
/// <param name="sender"></param>
/// <param name="e"></param>
void CanExecuteChanged(object sender, System.EventArgs e);
/// <summary>
/// Gets a value indicating whether this control and all its parents are enabled.
/// </summary>
bool IsEffectivelyEnabled { get; }
}
}

Loading…
Cancel
Save