5.5 Activating graphicals using the mouse

Recogniser objects enable detection of mouse- and keyboard activities. XPCE defines both primitive and complex recognisers. The first (called handler) processes a single event. The latter processes a gesture: sequence of events starting with a mouse-button-down up to the corresponding mouse-button-up. The following example allows us to move the icon by dragging with the middle mouse button:

11 ?- send(@ic, recogniser, new(move_gesture)).

The second example allows us to double-click on the icon. This is a common way to `open' an icon. In the example we will just print 'hello' in the Prolog window.

12 ?- send(@ic, recogniser,
           click_gesture(left, '', double,
                         message(@pce, write_ln, hello))).

The predefined recogniser classes are summarised in table 5. Besides the built-in recognisers, the XPCE/Prolog library defines various additional ones. See also section 11.8.

handler Binds a single event to a message.
handler_group Combines multiple recognisers into a single.
key_binding Maps keyboard sequences to commands.
click_gesture Maps a mouse-click to a message. Allows to specify modifiers (alt/meta, control, shift), button and multi (single, double, triple).
connect_gesture Connect two graphicals dragging from the first to the second.
move_gesture Move graphical by dragging it.
move_outline_gesture Move graphical by dragging an outline.
resize_gesture Resize graphical by dragging a side or corner.
resize_outline_gesture Resize graphical by dragging a side or corner of the outline.
Table 5 : Recogniser classes