Focus on Label Component in DialogWindow


#1

I have a dialog window that accepts a custom component which in tern has an editable label. For ease of use to the user I want the key cursor blinking and the label ready to accept input for speed save the user clicking on the label component.

I have read in previous posts that the label needs to be displayed before calling for focus.
My code calls this at time of creation

iptBox->grabKeyboardFocus();
iptBox->setWantsKeyboardFocus(true);

And I have tried those post the dialogWindow being shown.

I have also tried bringing the window to the front with this
savePresetWindow->toFront(true);

Then calling the above but can’t seem to gain focus… Am I missing something.

PS Jules shouldn’t answer as he promptly answered a question on Christmas Eve and New Years Eve…


#2

Create a Timer and in the callback set the focus.

Also check out this thread in case it’s relavent.

Rail


#3

Ok well I’ll test the using a timer callback. I have a polling system which is governed by an event timer callback anyway as I am using quite bit of threading in the application.

Had a read through some of the pointers in your post which I agree with however I should have pointed out that my application is standalone audio not a plugin, I would have gone down the component overlay model if it were but as its an app I wanted a separate window and focus for ease and with Return Key to finish input and close dialog which I have. Im just trying to make it as easy as possible from a UX perspective. Will let you know if the timer triggered focus works as there is only the one textbox in the window. Cheers.


#4

Ah ok so this actually pulls keyboard focus away (after mouse click and “is timer” is showing on my console so I know its grabKeyboardFocus function is the culprit. iptBox is Label component so does it have a child component I need to target?

InputDialogComponent::InputDialogComponent()
{
   startTimer(50);
}
InputDialogComponent::~InputDialogComponent()
{
    stopTimer();
}
void InputDialogComponent::timerCallback()
{
    std::cout << " is timer " << std::endl;
    iptBox->grabKeyboardFocus();
}

#5

K, Figured it, this feels a little dirty but it works so unless any better suggestions Im rolling with showEditor() call in timed callback then stoping the timer…

void InputDialogComponent::timerCallback()
{
    std::cout << " is timer " << std::endl;
    iptBox->showEditor();
    stopTimer();
}

#6

That looks right to me.

Cheers,

Rail