InterviewSolution
| 1. |
I've Fiddled With The Mask But Nothing Happened. Why? |
|
Answer» One common ERROR is to confuse gdk event TYPES with MASKs. The type number indicates precisely which gdk event was generated, but it is not directly related to the event mask: <jamesh_> yeah. A number of the masks cover multiple events and some events are SELECTED by different masks All event mask constants end with _MASK, and that is a good rule to remember. When doing add_events, you do NOT want (see, no _MASK!): widget.add_events(gtk.gdk.MOTION_NOTIFY | gtk.gdk.BUTTON_PRESS) This is the CORRECT command: widget.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK) (This example is particularly TRICKY because using BUTTON_PRESS will actually enable the pointer motion mask; this happens because the of the numeric constants used. Remember _MASK.) One common error is to confuse gdk event TYPEs with MASKs. The type number indicates precisely which gdk event was generated, but it is not directly related to the event mask: <jamesh_> yeah. A number of the masks cover multiple events and some events are selected by different masks All event mask constants end with _MASK, and that is a good rule to remember. When doing add_events, you do NOT want (see, no _MASK!): widget.add_events(gtk.gdk.MOTION_NOTIFY | gtk.gdk.BUTTON_PRESS) This is the correct command: widget.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_PRESS_MASK) (This example is particularly tricky because using BUTTON_PRESS will actually enable the pointer motion mask; this happens because the of the numeric constants used. Remember _MASK.) |
|