Progress bar tooltip

77 views
Skip to first unread message

Hannu Vuolasaho

unread,
Sep 25, 2014, 2:07:02 PM9/25/14
to fltkg...@googlegroups.com
Hi!

Is this known bug or am I doing it somehow wrong? Tooltip doesn't pop up. My FLTK is 1.3.2

int main(int argc, char **argv) {

  Fl_Window *window = new Fl_Window(340,340);
  Fl_Progress * prog = new Fl_Progress(50,280,280,12,"Test bar");
  prog->tooltip("Testing tooltip");
  window->end();
  window->show(argc, argv);
  return Fl::run();
}

Best regards,
Hannu Vuolasaho

greentea101

unread,
Sep 25, 2014, 4:02:22 PM9/25/14
to fltkg...@googlegroups.com
I just tested, and I don't know why this happens, but Fl_Tooltip::enter_() seems to never get called for Fl_Progress. As a workaround, you could slap an Fl_Group on top of the progress bar, and set the tooltip to that group rather than the progress bar.

Fl_Group grp(prog->x(), prog->y(), prog->w(), prog->h());
grp
.end();
grp
.tooltip("Testing tooltip");

Maybe someone more experienced (like one of the devs) has more insight into this, but that's all I've got right now.

greentea101

unread,
Sep 26, 2014, 6:42:53 AM9/26/14
to fltkg...@googlegroups.com
OK, I think I got it. It seems to me that the problem is Fl_Progress not implementing handle(), specifically the fact that it doesn't handle FL_ENTER.

In Fl_Group.cxx, line 198 is "if (send(o,FL_ENTER)) return 1;". This line calls send(), which in turn calls o->handle(event). But because Fl_Progress doesn't implement handle(), the base Fl_Widget::handle() is called, which returns 0, so send() returns 0, which then causes the flow of execution to reach line 202 ("Fl::belowmouse(this);"), which sets the "belowmouse" widget to the containing Fl_Window, which then causes line 194 ("if (o->contains(Fl::belowmouse())) {") to fail and keep failing, repeating the cycle endlessly. Long story short, the "belowmouse" widget is never set to the Fl_Progress.

To fix this, we need to handle() FL_ENTER in the Fl_Progress class.

In Fl_Progress.H:
public:
virtual int handle(int);

In Fl_Progress.cxx:
int Fl_Progress::handle(int e)
{
   
if(e == FL_ENTER || e == FL_LEAVE) return 1;
   
return 0;
}

I haven't looked at the possibility of this breaking something (have to go to bed), but it seems very unlikely.
Reply all
Reply to author
Forward
0 new messages