diff --git a/build/linux/platform_specific_code/juce_linux_Windowing.cpp b/build/linux/platform_specific_code/juce_linux_Windowing.cpp index 27794b3873..c869e654cd 100644 --- a/build/linux/platform_specific_code/juce_linux_Windowing.cpp +++ b/build/linux/platform_specific_code/juce_linux_Windowing.cpp @@ -1076,6 +1076,10 @@ public: } } + void textInputRequired (int /*x*/, int /*y*/) + { + } + void repaint (int x, int y, int w, int h) { if (Rectangle::intersectRectangles (x, y, w, h, diff --git a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp index 68a4034a1c..c4d74f3723 100644 --- a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp @@ -751,6 +751,10 @@ public: } } + void textInputRequired (int /*x*/, int /*y*/) + { + } + //============================================================================== void repaint (int x, int y, int w, int h) { diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index e7f3779b5e..0e744b38aa 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -484,6 +484,7 @@ public: fullScreen (false), isDragging (false), isMouseOver (false), + hasCreatedCaret (false), currentWindowIcon (0), taskBarIcon (0), dropTarget (0) @@ -819,6 +820,18 @@ public: shouldDeactivateTitleBar = oldDeactivate; } + void textInputRequired (int x, int y) + { + if (! hasCreatedCaret) + { + hasCreatedCaret = true; + CreateCaret (hwnd, 0, 0, 0); + } + + ShowCaret (hwnd); + SetCaretPos (x, y); + } + void repaint (int x, int y, int w, int h) { const RECT r = { x, y, x + w, y + h }; @@ -901,7 +914,7 @@ public: private: HWND hwnd; DropShadower* shadower; - bool fullScreen, isDragging, isMouseOver; + bool fullScreen, isDragging, isMouseOver, hasCreatedCaret; BorderSize windowBorder; HICON currentWindowIcon; NOTIFYICONDATA* taskBarIcon; @@ -1976,6 +1989,12 @@ private: break; case WM_KILLFOCUS: + if (hasCreatedCaret) + { + hasCreatedCaret = false; + DestroyCaret(); + } + handleFocusLoss(); break; diff --git a/src/juce_appframework/gui/components/controls/juce_TextEditor.cpp b/src/juce_appframework/gui/components/controls/juce_TextEditor.cpp index 9cc520c57c..6d1d304020 100644 --- a/src/juce_appframework/gui/components/controls/juce_TextEditor.cpp +++ b/src/juce_appframework/gui/components/controls/juce_TextEditor.cpp @@ -2104,6 +2104,11 @@ void TextEditor::focusGained (FocusChangeType) if (caretVisible) textHolder->startTimer (flashSpeedIntervalMs); + + ComponentPeer* const peer = getPeer(); + if (peer != 0) + peer->textInputRequired (getScreenX() - peer->getScreenX(), + getScreenY() - peer->getScreenY()); } void TextEditor::focusLost (FocusChangeType) diff --git a/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp b/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp index e11dbd618d..f8e822cc68 100644 --- a/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp +++ b/src/juce_appframework/gui/components/special/juce_MagnifierComponent.cpp @@ -82,6 +82,13 @@ public: peer->grabFocus(); } + void textInputRequired (int x, int y) + { + ComponentPeer* peer = magnifierComp->getPeer(); + if (peer != 0) + peer->textInputRequired (x, y); + } + void getBounds (int& x, int& y, int& w, int& h) const { x = magnifierComp->getScreenX(); diff --git a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h index b9c810221a..9e2d63a2f2 100644 --- a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h +++ b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h @@ -254,6 +254,13 @@ public: /** Tries to give the window keyboard focus. */ virtual void grabFocus() = 0; + /** Tells the window that text input may be required at the given position. + + This may cause things like a virtual on-screen keyboard to appear, depending + on the OS. + */ + virtual void textInputRequired (int x, int y) = 0; + /** Called when the window gains keyboard focus. */ void handleFocusGain(); /** Called when the window loses keyboard focus. */