define-operation ( pred command flags -- ) (original) (raw)

define-operation ( pred command flags -- )
Factor handbook » UI framework » Implementing new gadgets » UI gestures » Operations

Prev: operation
Next: primary-operation ( obj -- operation )

Vocabulary
ui.operations

Inputs

pred a quotation with stack effect ( obj -- ? )
command a word
flags a hashtable

Outputs
None

Word description
Defines an operation on objects matching the predicate. The hashtable can contain the following keys:

+listener+ - if set to a true value, the operation will run in the listener
+description+ - can be set to a string description of the operation
+primary+ - if set to a true value, the operation will be output by primary-operation when applied to an object satisfying the predicate
+secondary+ - if set to a true value, the operation will be output by secondary-operation when applied to an object satisfying the predicate
+keyboard+ - can be set to a keyboard gesture; the gesture will be used by define-operation-map

Definition

USING: assocs kernel ui.commands ;

IN: ui.operations

: define-operation ( pred command flags -- )
default-flags swap assoc-union dupd define-command
(define-operation) ;