Skip to content

Commit

Permalink
Redo hotkey CanExecute before Execute
Browse files Browse the repository at this point in the history
  • Loading branch information
Hosch250 committed Jul 14, 2016
1 parent 133968c commit 0b128f9
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions RetailCoder.VBE/Common/RubberduckHooks.cs
Expand Up @@ -5,21 +5,17 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Input;
using Microsoft.Vbe.Interop;
using Rubberduck.Common.Hotkeys;
using Rubberduck.Common.WinAPI;
using Rubberduck.Settings;
using Rubberduck.UI.Command;
using Rubberduck.UI.Command.Refactorings;
using NLog;
using Rubberduck.UI;

namespace Rubberduck.Common
{
public class RubberduckHooks : IRubberduckHooks
{
private readonly VBE _vbe;
private readonly IntPtr _mainWindowHandle;
private readonly IntPtr _oldWndPointer;
private readonly User32.WndProc _oldWndProc;
Expand All @@ -34,7 +30,6 @@ public class RubberduckHooks : IRubberduckHooks

public RubberduckHooks(VBE vbe, IGeneralConfigService config, IEnumerable<CommandBase> commands)
{
_vbe = vbe;
_mainWindowHandle = (IntPtr)vbe.MainWindow.HWnd;
_oldWndProc = WindowProc;
_newWndProc = WindowProc;
Expand Down Expand Up @@ -175,7 +170,7 @@ public void Detach()
private void hook_MessageReceived(object sender, HookEventArgs e)
{
var hotkey = sender as IHotkey;
if (hotkey != null)
if (hotkey != null && hotkey.Command.CanExecute(null))
{
hotkey.Command.Execute(null);
return;
Expand Down

0 comments on commit 0b128f9

Please sign in to comment.