TextEditor::Listener from Slider?


#1

I want to get the textEditorFocusLost event from the Slider's TextEditor. I'm not sure how best to go about it. I have added the TextEditor::Listener to my component and added the virtual functions, but its not triggering the textEditorFocusLost function. 

Is there a way to accomplish this using the JUCE Slider or do I need to create a subclass?

 


#2

Wouldn't it make more sense to use the sliderDragEnded callback, which should be called when the text has been changed and the box is dismissed?

 


#3

Thanks, that takes me part of the way there - what I want is a callback that is triggered when the TextEditor loses focus and turns back into a Label. 

I need this so that I can hide my custom virtual keyboard when the user clicks or presses outside the Slider's TextEditor.


#4

OK, realised where I was going wrong, I've modified the showKeyboard method in the Java Activity - made some adjustments there and now works as expected. 


#5

If you're doing a virtual keyboard, the correct approach would be to not make any changes to the label, but to deal with TextInputTargets directly. There's a method ComponentPeer::findCurrentTextInputTarget() which you could call when the focus changes (use the Desktop class to create a global focus watcher), and then show your keyboard when an input target is active.


#6

Great info thanks Jules, that will help me if I decide to go with a native virtual keyboard.