Touch Keyboard on windows




anyone have a clue on how to make on windows that on a TextEditor component, when clicked, will call a touch keyboard, like what happens in Android or iOS ?




No one have any suggestion or idea ?


I'd have expected it to already work - it has used the win32 input method hooks for a long time (see TextInputTarget). Haven't actually tried it myself in win8 though.


Thank you Jules for guidance.


Is there any example on the implementation of this method ?


You don't need to implement it, it's already used by things like TextEditor.


Yes, i believe it should be, and in iOS and Android the touch keyboard is showned. But on Windows or MacOS or Linux, nothing happens, so how to use it.

When i click inside a TextEditor, how to detect it and call a component ?

My idea was when detecting that a TextEditor was clicked to call a component that will show a touch keyboard layout, and all keys pressed on this component, will send in a callback function all keystrokes to the TextEditor that called it.

Is this a wrong way to think ?



I've made a component that is like a keyboard, with all keys and functions and when i press any button it writes it to a TextEditor component that is inside my touch keyboard.

I've managed to call the keyboard when i click inside a textEditor component.

My question now is, should i call this touch keyboard component as a modal component ?

How can i pass the result of the touch keyboard (text typed) to the TextEditor component that called it ?

Can anyone give me a guidance on the best way to do it ?




Help to understand this:

I have a TextEditor that when clicked inside will call a modal component.

If I want to pass a string from my modal component to my TextEditor component, I can do it using a Broadcaster and a Listener ?

I have to put a Listener that when receives a message from the Broadcaster of the modal component, will update the text of my TextEditor ?

Am I thinking right ?




Sounds about right to me. You should place some breakpoints into your listener callbacks to see if they are being triggered when the user updates something in the modal component. If not they might not have be registerd correctly.


Thanks Rory,


seems something is missing for me to be able to make it work.

If I call my component as modal this way:

    childComponent = new Keypad();
    childComponent->setSize(250, 320);
    childComponent->setTopLeftPosition(100, 100);

    if (modal)
        (void)modal; // (to avoid an unused variable warning)

        childComponent->enterModalState(true, ModalCallbackFunction::forComponent(frontCallback, this), true);

I'm releasing it after I make it enter modal. Perhaps I'm calling it on a wrong way.

So how to had a listener, and how do I broadcast from this childComponent ?




From the Juce docs

"running modal loops is evil and must never be done"

Have you tried using a CallOutBox?

You set your componet to be the content component. So soemthing like this:

void eventToTriggerModalComp()
CallOutBox& myBox = CallOutBox::launchAsynchronously (Keypad, getScreenBounds(), nullptr);

Your KeyPad class should inherit ChangeBroadcaster. Your main component should should inherit ChangeListener. When you do this you will need to a void changeListenerCallback (ChangeBroadcaster *source) method in your main component as it's a pure virtual member function of ChangeListener. Then when you create your KeyPad object do this:

childComponent = new Keypad();

When you want to trigger the changeListenerCallback function in your main component just send call 'sendChangeMessage(). Btw, you may find the actionListener/broadcaster mechanism easier to work it. It lets you pass simple strings from the broadcaster to the listener. It's more lightweight, but to be honest, should probably makes things a little more straight forward. You can set them up in the same way as change listeners/boardcasters.