Give/Set focus
-
We have
loseFocus
but is there a way to set a control as having focus? For example I have an editable label and a button to clear the label, it would be nice to give focus to the label when the clear button is clicked. -
@d-healey I agree, it would be handy!
-
@d-healey how does losefocus work? I’m always trying to control the transport in a daw while my plugin is open and end up controlling the plugin instead
-
-
@d-healey trying to implement the functions but I'm stuck trying to get the component;
void ScriptingApi::Content::ScriptLabel::showEditor() { if (auto l = dynamic_cast<ScriptLabel*>(get()how?????)) { l->showEditor(); } ) void ScriptingApi::Content::ScriptLabel::hideEditor(bool discardContent) { if (auto l = dynamic_cast<ScriptLabel*>(get()how?????)) { l-> hideEditor(discardContent); } )
Should I dynamic_cast at least? @Christoph-Hart
-
Depending on where you're putting this code it might be:
ScriptingApi::Content::ScriptLabel* thisObject = GET_OBJECT(Content::ScriptLabel)
or
MultilineLabel *l = dynamic_cast<MultilineLabel*>(component.get());
or
ScriptingApi::Content::ScriptLabel *sl = dynamic_cast<ScriptingApi::Content::ScriptLabel*>(getScriptComponent());
or
Something else...
-
@d-healey I tried 1, 3, and many of the 4... Trying 2 ;)
also trying(this)
-
@d-healey Also I'm not sure the hideEditor will work, because clicking outside the label might be caught before anyway...
EDIT: if we really need a discardContent bool, maybe it is possible to add it in the properties then...
-
It would be nice to have this. Giving focus to a user-input label when clicking on a button for example, as David suggested.
@Christoph-Hart would that be possible to implement please ? :)