how to associate a &Label with a [Widget]

13 views
Skip to first unread message

Mark

unread,
Dec 14, 2021, 5:16:39 AM12/14/21
to fltk.general
I have a label (a Frame with some text) and a widget beside it (a Spinner).
I'd like to have the label have an underlined letter (which in a button is achieved using &Click) but doesn't seem to work in a Frame's label. And when the user presses Alt+C (i.e., Alt+_underlined letter_) sends the keyboard focus to an associated widget.

How is this done in FLTK?

Mark

unread,
Dec 14, 2021, 6:02:03 AM12/14/21
to fltk.general
I solved this by making my labels Buttons with a NoBox frame type and setting their callbacks to widget.take_focus() for their associated widgets.

Ian MacArthur

unread,
Dec 14, 2021, 11:50:23 AM12/14/21
to fltk.general
This is fltk-rs I assume, so your "Frame" is what we'd call a box, I believe?

I'm not sure about spinner labels - under C++ I think I'd expect that to just have worked though - but I haven't actually checked! Odd... Oh! The action is on the Frame, not the spinner? Hmm, is the frame basically an Fl_Box with just a label in it? You should still be able to capture events from a Fl_Box  though...
Using a dummy button sounds like a credible solution here though.

As an aside, I think I'd set the button to Flat_Box rather than NoBox here, as that will ensure the label is less likely to be "damaged" by other refresh actions and so forth.


 
Reply all
Reply to author
Forward
0 new messages