A gesture is a recogniser object for a sequence of events, starting with a (mouse-) button down event up to the corresponding up-event.
Class gesture
itself takes care of detecting the appropriate down event that matches
the specified modifier
object. Next, it sets the event focus using window->focus
on the window on which the event occurred to itself and maintains this
focus until the corresponding up-event is detected. As the execution of
a specific gesture is often indicated to the user by using some cursor
object, class gesture
allows for the specification of a cursor during the execution of the
event.
Class gesture itself is intended to act a a super-class over classes that handle particular gestures such as moving, resizing, linking graphicals, clicking, etc. The predefined subclasses are:
->connect).
A gesture sends 4 types of messages to itself for which a sub-class of gesture must define appropriate behaviour
->verify:
event Called after a down-event of the appropriate button with the
appropriate modifier is detected. It should succeed if the condition to
actually start this gesture are satisfied. Normally used to perform
checks on the mode of the tool or represented object, etc. Class gesture
itself defines a verify behaviour that succeeds without side-effects.
->initiate:
event Called right after the gesture->verify
succeeded. It should perform the necessary initialisations for starting
the gesture. If the class-variable cursor is not @default,
the cursor will be set automatically.
->drag:
event Called on each mouse-motion event that is received.
->terminate:
event Called on the corresponding up-event. It should terminate the
gesture. The cursor is automatically reset to its original value.
left, middle or right.
Mouse-events associated with any other button are always ignored by the
gesture.
@receiver: The gesture @arg1 Equivalent to @event
If this message fails, the gesture is not activated.
Defaults: @nil
->initiate
method or set this variable to
@default and
invoke graphical->focus_cursor
in gesture->initiate.
active, the gesture is
initiated and processing events.
->cancel
and click_gesture<-max_drag_distance.
It performs the following steps:
->active: @off
->focus
of the associated window
->active: @on
->event
if the gesture<-status
attribute is active and the event is a drag event (i.e.
the mouse is moved with one of the buttons held down).
gesture->drag
just succeeds. Intended to be redefined by gesture's subclasses.
<->modifier,
the button matches gesture<->button,
the gesture<->condition
message is @nil
or executed successfully and gesture->verify
succeeds, the gesture will perform the following steps:
->initiate:
Event on itself to initiate
<-status
to active
->focus
to grab the event-focus
<-status
equals active, invokes gesture->drag:
event to itself
<-status
equals active and the button matches the gesture<->button
of the gesture, invoke gesture->terminate
on itself and set gesture<->status
to inactive.
Fails when recogniser<->active
equals @off.
Specification through class_variable/4 is advised as this allows the user to set his/her own preferences and it will give all similar gestures consistent user-interface.
Creating instances of this class is no common use. Note however that
a recogniser for a specific application may be created by creating an
instance of class recogniser
and attaching the necessary gesture->initiate,
gesture->verify, gesture->drag
and/or gesture->terminate
methods to it using object->send_method.
->event
on a button-down event when all conditions are verified. This method
should perform necessary initialisation for the gesture.
gesture->initiate
just succeeds. Intended to be redefined by gesture's subclasses.
->event
when the matching button-up event that terminates the gesture action
occurs.
gesture->terminate
just succeeds. Intended to be redefined by gesture's subclasses.
->event
on the button-down event after the button, modifier and condition have
been verified. This method may do additional verification. It is
supposed to succeed or fail without side-effects. Side-effects necessary
during initiation of the gesture should be defined at gesture->initiate.
gesture->verify
just succeeds. Intended to be redefined by gesture's subclasses.