Skip to content

Commit d0f2327

Browse files
committed
Detach hotkeys based on window focus.
1 parent afea73b commit d0f2327

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,21 @@ private IntPtr WindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
216216
try
217217
{
218218
var suppress = false;
219-
if (hWnd == _mainWindowHandle && (WM)uMsg == WM.HOTKEY)
219+
switch ((WM) uMsg)
220220
{
221-
suppress = HandleHotkeyMessage(wParam);
221+
case WM.HOTKEY:
222+
suppress = hWnd == _mainWindowHandle && HandleHotkeyMessage(wParam);
223+
break;
224+
case WM.SETFOCUS:
225+
Attach();
226+
break;
227+
case WM.NCACTIVATE:
228+
case WM.CLOSE:
229+
if (wParam == IntPtr.Zero)
230+
{
231+
Detach();
232+
}
233+
break;
222234
}
223235

224236
return suppress

0 commit comments

Comments
 (0)