Function that gives TextBox coordinates


#1

Hello !

I’m working a layout, and that would be a great addition if there was a function like getTextBoxWidth() or getTextBoxHeight(), but with the X and Y coordinates.
Is there already something that does that, and I didn’t see it ?

Thanks !


#2

If you are talking of the Slider’s TextBox, this is done in the look and feel:
Slider::LookAndFeelMethods::createSliderTextBox()

It is called in lookAndFeelChanged:

But the valueBox is part of the private implementation (PIMPL), so the slider cannot grant you access to the component.
However you can see how the lookandfeel computes the position and use the same arithmetic.
Or see if you can change the lookandfeel by subclassing and keep a reference to the valueBox when it is created. But you should have a good understanding for the architecture to do so, especially when it comes to objects lifetime and ownerships.


#3

Alright, I’ll check how the position is computed and try to mirror it for my label :wink:

Thanks a lot !