Re: How to create a label that moves along with the mouse cursor?



Dear Niko and others,

> You could just do this:
> [...]

Thanks for the hint. I now succeeded into doing something that comes very
close to what I want. In the on_motion_notify_event method of my window I
now perform movement of another window that should show the value that I
want to show. See the code fragment below. "Values" is the type of a
widget that shows a smaller window moving along with the mouse cursor if
it moves over the widget of type "Values". "num" is the variable that
stores this smaller window.

bool Values::on_motion_notify_event(GdkEventMotion* event)
{  int root_x, root_y;
   get_parent_window()->get_position(root_x, root_y);
   Allocation a = get_allocation();
   int xpos = root_x + a.get_x() + int(event->x) + 10;
   int ypos = root_y + a.get_y() + int(event->y) + 10;
   num.move(xpos , ypos);
   if (!numwindow_open)
   {  num.set_skip_taskbar_hint(true);
      num.set_decorated(false);
      num.show();
      numwindow_open = true;
   }
[...]
}

All the best,
Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]