| @@ -206,6 +206,52 @@ namespace | |||||
| } | } | ||||
| } | } | ||||
| //============================================================================== | |||||
| static HHOOK keyboardHook = 0; | |||||
| static int keyboardHookUsers = 0; | |||||
| LRESULT CALLBACK keyboardHookCallback (int nCode, WPARAM wParam, LPARAM lParam) | |||||
| { | |||||
| if (nCode == 0) | |||||
| { | |||||
| const MSG& msg = *(const MSG*) lParam; | |||||
| if (msg.message == WM_CHAR) | |||||
| { | |||||
| Desktop& desktop = Desktop::getInstance(); | |||||
| HWND focused = GetFocus(); | |||||
| for (int i = desktop.getNumComponents(); --i >= 0;) | |||||
| { | |||||
| if ((HWND) desktop.getComponent (i)->getWindowHandle() == focused) | |||||
| { | |||||
| SendMessage (focused, msg.message, msg.wParam, msg.lParam); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return CallNextHookEx (mouseWheelHook, nCode, wParam, lParam); | |||||
| } | |||||
| void registerKeyboardHook() | |||||
| { | |||||
| if (keyboardHookUsers++ == 0) | |||||
| keyboardHook = SetWindowsHookEx (WH_GETMESSAGE, keyboardHookCallback, | |||||
| (HINSTANCE) Process::getCurrentModuleInstanceHandle(), | |||||
| GetCurrentThreadId()); | |||||
| } | |||||
| void unregisterKeyboardHook() | |||||
| { | |||||
| if (--keyboardHookUsers == 0 && keyboardHook != 0) | |||||
| { | |||||
| UnhookWindowsHookEx (keyboardHook); | |||||
| keyboardHook = 0; | |||||
| } | |||||
| } | |||||
| #if JUCE_WINDOWS | #if JUCE_WINDOWS | ||||
| static bool messageThreadIsDefinitelyCorrect = false; | static bool messageThreadIsDefinitelyCorrect = false; | ||||
| #endif | #endif | ||||
| @@ -1291,6 +1337,9 @@ public: | |||||
| addMouseListener (this, true); | addMouseListener (this, true); | ||||
| registerMouseWheelHook(); | registerMouseWheelHook(); | ||||
| if (PluginHostType().isAbletonLive()) | |||||
| registerKeyboardHook(); | |||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -1298,6 +1347,7 @@ public: | |||||
| { | { | ||||
| #if JUCE_WINDOWS | #if JUCE_WINDOWS | ||||
| unregisterMouseWheelHook(); | unregisterMouseWheelHook(); | ||||
| unregisterKeyboardHook(); | |||||
| #endif | #endif | ||||
| deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may | deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may | ||||