I have an FL_Input that sometimes needs to display a text field that is wider than the widget. Can I control which 'side' of the text is shown?
Let's say our Fl_Input is wide enough to show 5 characters -- and that our string is 123.456.
Currently, the Fl_Input will display "3.456" while I would prefer that it display "123.4".
I am aware of the things you can set via _Fl_Input::type() -- but there does not seem to be anything relevant there.
Any suggestions?
You probably just need to change the cursor position to 0
after pre-setting the field's value,
and after the user finishes entering a value (when they hit
ENTER or when they navigate
off the field).
The docs say Fl_Input_::position(int p) is how to set the
cursor position, so try
setting that to 0 after changing the value(), and ditto for
the callback, assuming
you set when() to a value appropriate for your widget so the
callback is invoked
at the right times.
You can also preselect the text, so if someone navigates to
the field and starts
typing a new value, since it's preselected, typing the first
character replaces the
old value (instead of inserting). The user has the option to
deselect first.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/0138d475-de14-44d8-be22-0ddaf269a0acn%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/q3C4-P9v-7s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAL-8oAhDMhi5RH6NsuUJ4%3Dc_pHE%3DT5%3D-HMPAg-b3Xt0Wq-5Keg%40mail.gmail.com.
Where/how does a Widget render text? A Fl_Button with a label that is too-long justifies the 'other' way. I am fine subclassing Fl_Input to make this work the way I'd like, but I'm not sure where to start.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/0ab867a7-a9e5-439a-84d2-ec99df55bdfan%40googlegroups.com.
I would try moving the cursor to the start when you lose focus
I will have to work to see if I can construct an example that others can try.
On 3/13/23 22:26, Rob McDonald wrote:
I will have to work to see if I can construct an example that others can try.
OK, here (attached) is an example based on one of Erco's cheat sheet examples...I've modified it to call position(0) at the places required to get the behavior I'm after -- but it results in the non-erasing cursor.
I may have missed part of this thread; calling redraw() on
the widget after calling
position() should fix this, as it "should" mark the entire
input widget damage()ed
and force it to redraw everything in it completely.
I am calling position() in two places -- in the handle() and after setting the value() when the 'other' widget's callback is activated.
Should I call redraw() after both?
Calling input->redraw() seems like the right thing to do
to me.
The equivalent would be input->damage(FL_DAMAGE_ALL);
Doing either one of those seems like the right thing to do in
this case.
If you wanted to be super efficient, you could check if
position()
is already at the value you're setting to avoid forcing a
redraw
unnecessarily, but that's about as far as I'd go to optimizing
at the widget hierarchy level you're working at.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/9e4b3d77-507e-0400-247a-b3f372832cdc%40seriss.com.