1.27 class click_gesture

A click_gesture can be used to make any graphical behave as a button. It allows you the mouse-button that should be recognised; the state of the modifier buttons and the multiclick status (single, double, triple clicks).

The above forms the condition part. The action part consists of three messages. When the mouse goes down, the click_gesture<-preview_message is sent. Next, when the mouse goes up inside the area of the graphical, the click_gesture<-execute_message is activated, otherwise the click_gesture<-cancel_message. For all these messages, the following arguments are forwarded:

@receiver The receiving graphical object
@arg1 The event

Normally, the click_gesture<-preview_message indicates that releasing the button here will start some command. The execute message will execute the command and remove the feedback provided by the preview and the cancel message just removes this feedback.

See also
- event<-multiclick
- class button

1.27.1 Instance variables

click_gesture <-> cancel_message: code*
The cancel_message is executed when the user releases the button that initiated this click gesture outside the area of the graphical this gesture is associated with. When executed, the following arguments are forwarded:
@receiver		Graphical on which the gesture was started
@arg1		Event

When @nil, no cancel message is sent.

Defaults: Default is @nil (no cancel message is sent)

click_gesture <-> execute_message: code*
This message is sent when the user releases the button that initiated this gesture inside the area of the graphical. The argument bindings are:
@receiver The graphical
@arg1 The event

When @nil, no message is sent.

Defaults: @nil (no message)

click_gesture <-> max_drag_distance: int*
This variable is used by click_gesture->drag to cancel the click_gesture after the user dragged too far. @nil implies the gesture is never canceled by dragging.
click_gesture <-> multiclick: [{single,double,triple}]
The multiclick attribute determines whether the gesture reacts on single, double or triple click.

Defaults: single

click_gesture <-> preview_message: code*
The preview message is sent when the gesture is initiated (i.e. on the down event). The following arguments are passed:
@receiver The graphical
@arg1 The event

When @nil, no message is sent.

Defaults: @nil (no message is sent).

1.27.2 Send methods

click_gesture ->cancel: event
Forward click_gesture<-cancel_message (if any) and cancel the gesture using gesture->cancel. Called from click_gesture->drag if the user dragged too far.
click_gesture ->drag: event
If click_gesture<-max_drag_distance is not @nil, determine the distance between the original down event and the current event and click_gesture->cancel if this distance exceeds click_gesture<-max_drag_distance pixels.
click_gesture ->initialise: button=[button_name], modifier=[modifier], multiple=[{single,double,triple}], message=[code]*, preview=[code]*, cancel=[code]*
Initialises a click_gesture from the following arguments:
buttonMouse-button: {left,middle,right}
modifierModifier status
multiclickMulticlick status: {single,double,triple}
execute_messageRan when click is finished (up)
preview_messageRan when click is started (down)
cancel_messageRan on up outside area

Defaults: button Resource defined (left) modifier Resource defined (none) multiclick Resource defined (single) execute_message @nil preview_message @nil cancel_message @nil

click_gesture ->initiate: event
When click_gesture<-preview_message is not @nil, forward this message.
click_gesture ->terminate: event
Executes click_gesture<-execute_message iff the pointer is not moved outside the area of the graphical for which this gesture was started or the pointer has been moved less than 5 pixels.

Otherwise the click_gesture<-cancel_message is executed when it is not @nil