1.124 class popup_gesture

A popup_gesture is used to show a popup object. It event->posts all incoming events to the popup-menu and requests the popup to execute the selected command after the user releases the button that caused the gesture to activate the popup.

Many classes define methods for associating popup objects using the method graphical->popup or a redefinition thereof. Direct use of instances of this class is often not necessary.

See also
- graphical->popup
- class popup

1.124.1 Instance variables

popup_gesture <-> context: any
The argument for which the popup is ran. Normally this is the receiving graphical object. However, it is possible to rebind the context in the popup_gesture->initiate method. For example, class list_browser sets the popup_gesture<-context to the dict_item object under the pointer.

See also popup_gesture->terminate.

popup_gesture <-> max_drag_distance: int*
If @nil, the popup shows immediately on the down event and may be selected by dragging to an item. If an integer the gesture behaves like a click_gesture object. If the user drags more than the specified distance the gesture is popup_gesture->cancel’ed otherwise the menu is displayed on the up event.
popup_gesture <-> popup: popup|function*
Popup displayed by the gesture. If is a function object, it is evaluated by popup_gesture->verify using the following arguments:
@arg1 event<-master (normally receiving graphical)
@arg2 The event (normally @event)

The slot -current is filled with the result.

1.124.2 Send methods

popup_gesture ->drag: event
Drag just passes incoming drag-events to the displayed popup menu.
popup_gesture ->event: event
First runs gesture->event. When not successful and the event is a keyboard event, popup->key will be invoked with the key description. This facility makes keyboard accelerators associated with the popup active.
popup_gesture ->initialise: popup=[popup|function], button=[button_name], modifier=[modifier]
Create from popup object, button name and modifier. By default is a popup associated to the right button. Note that the popup argument may be a function. See popup_gesture<-popup.
popup_gesture ->initiate: event
Initiate performs the following actions:
[|](112, [111,112,117,112,32,45,62,117,112,100,97,116,101,58,32,67,111,110,116,101,120,116])
Allow the popup to change it's menu_items before it is shown.
[|](112, [111,112,117,112,32,45,62,111,112,101,110,58,32,82,101,99,101,105,118,101,114,44,32,80,111,115,105,116,105,111,110])
Actually display the popup. The receiver passed is the receiver of the event, the position is the position of the event, relative to the receiver.
[|](101, [118,101,110,116,32,45,62,112,111,115,116,58,32,80,111,112,117,112])
Post the event to the popup
See also
- popup->open
- popup->update
popup_gesture ->terminate: event
The terminate method performs the following:

popup_gesture ->verify: event
Verify tries to find the popup-menu to be displayed and sets the -context attribute of the popup_gesture to the event-receiver if it is not set to @nil.

If the popup_gesture<->popup attribute of the gesture is set, this popup menu is used. If it is a function object, the function is evaluated. See popup_gesture<-popup.

Otherwise, the event<-master is requested a popup with popup_gesture<-popup.

After finding a popup object, this object is sent popup->update to update its menu_items. If, after graphical<-active or‘popup popup_gesture<-members’is empty, popup_gesture->verify fails.