开发者

Gtk::Widget on_enter_notify when mouse is down?

I'm trying to have a list of Gtk::Widgets that when clicked on I need to highlight the widge开发者_如何学编程t, but when the user holds the button down, and drags to another widget, the first one will 'unhighlight' and the new one will highlight on enter_notify.

I've tried using the on_enter_notify_event, and on_button_press_event in multiple combinations ( yes, I'm adding the events ), but every time I 'press' the widget, it starts a drag event, and enter_notify and leave_notify won't fire.

Is there a way to ignore the drag event? I've tried ending it when it starts, but I think the problem is the on_notify won't trigger with the mouse down. Is there another way of doing it?

Any help or suggestions would be greatly appreciated.


Okay, apparently when a widget gets activated or clicked, the GdkDevice 'grab()'s the widget and only sends events to THAT widget. So I've taken the device from the event, and called 'ungrab()' on it so it allows the other cells to receive events. Then on my other cells I check the event->state in the on_enter_notify_event to see if the mouse is down, and voila! The cell is highlighted.

bool cell::on_button_press_event(GdkEventButton* event) {
  highlight_cell();

  gdk_device_ungrab(event->device, event->time);

  return true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜