When a widget's label lies outside the widget, and the
label is changed to a shorter label, redraw_label() does
not clear out the excess text left over from the longer
label
I've worked around this by calling redraw() on the
parent window, but (1) this seems crude, (2) the parent
window isn't always handy (will the parent group do it? I don't
know), and (3) I can't tell from the docs if this is supposed
to work reliably.
The following should illustrate. My main question is whether or
not there's a reliable way to accomplish what I want to do: replace
a label with a shorter one and have the old one go away.
TIA,
Stan
#include "FL/Fl_Double_Window.H"
#include "FL/Fl_Input.H"
#include "FL/Fl_Button.H"
#include "FL/Fl.H"
void btn_cb(Fl_Widget*, void* inp)
{
static int toggle = true;
Fl_Input* input = static_cast<Fl_Input*>(inp);
if(toggle) {
input->label("XXXXXXXXXXXXXXXXXXXXXXX");
}
else {
input->label("OO");
}
// this works
//input->parent()->redraw();
// this doesn't
input->redraw_label();
toggle = !toggle;
}
int main()
{
Fl_Double_Window window(400, 400);
Fl_Input input(200, 100, 100, 20);
Fl_Button btn(0, 0, 30, 30);
btn.callback(btn_cb, &input);
window.end();
window.show();
return Fl::run();
}
~
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk