[java-gnome-hackers] How to deal with MotionNotifyEvent?
Brought to you by:
afcowie
From: Vreixo F. L. <met...@ya...> - 2009-05-17 02:37:56
|
Hi everybody, I need to expose motion-notify-event Widget signal to use it in an app. This event, however, is only received after "activating" it, i.e., passing the GDK_POINTER_MOTION_MASK to the gdk_window_set_events, that of course requires a GdkWindow to be available. I've seen that for VisibilityNotifyEvent, that also requires similar procedure, you take care of that internally, hidden for the user. That is great! However, for motion notify I don't know if that is a good idea. It generates a lot of events, while usually you only take care about them sometimes. For example, in my application I use this event to move a chart on a cairo drawing area when the user keeps the left button pressed. However, if the user release the button I do not care about this event at all. If I enable it when connecting to the signal, I will receive a lot of events in my app. In my opinion, it is better to allow users to enable/disable such kind of events when needed. However, the enable/disable procedure is rather complex, and ugly, as it requires knowledge about the underlying GdkWindow details. If event signals are part of Widget, I think enable/disable should be there. My proposal would be to add a pair of methods to Widget: enableEvent() disableEvent() that take a EventMask as parameter. Such methods would get the GdkWindow, realizing the widget if needed (as you do in GtkWidgetOverride for visibility event), and enable/disable the given events, left the other events untouched. Then, events such as motion notify should document the procedure. This way, underlying details are hidden for the user. In my opinion, that would be much easy to understand for users. However, it has a problem, too, as if two widget share the same GdkWindow, the behavior of enable/disable methods could be confusing. Anyway, I think that good documentation can explain this. What do you think? Do you like the idea? Cheers Vreixo Veja quais são os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.com |