Interactions (interactions)
User Interaction Handlers
User interaction handlers for a SchemeEditWidget.
User interactions encapsulate the logic of user interactions with the scheme document.
All interactions are subclasses of UserInteraction.
- class orangecanvas.document.interactions.UserInteraction(document: SchemeEditWidget, parent: QObject | None = None, deleteOnEnd: bool = True)[source]
Bases:
QObjectBase class for user interaction handlers.
- Parameters:
document (
SchemeEditWidget) – An scheme editor instance with which the user is interacting.parent (
QObject, optional) – A parent QObjectdeleteOnEnd (bool, optional) – Should the UserInteraction be deleted when it finishes (
Trueby default).
- started()
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- finished()
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- ended()
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- canceled()
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- NoReason = 0
No specified reason
- UserCancelReason = 1
User canceled the operation (e.g. pressing ESC)
- InteractionOverrideReason = 3
Another interaction was set
- ErrorReason = 4
An internal error occurred
- OtherReason = 5
Other (unspecified) reason
- start() None[source]
Start the interaction. This is called by the
CanvasScenewhen the interaction is installed.Note
Must be called from subclass implementations.
- end() None[source]
Finish the interaction. Restore any leftover state in this method.
Note
This gets called from the default
cancel()implementation.
- postQuickTip(contents: str) None[source]
Post a QuickHelpTipEvent with rich text contents to the document editor.
- mousePressEvent(event: QGraphicsSceneMouseEvent) bool[source]
Handle a QGraphicsScene.mousePressEvent.
- mouseMoveEvent(event: QGraphicsSceneMouseEvent) bool[source]
Handle a GraphicsScene.mouseMoveEvent.
- mouseReleaseEvent(event: QGraphicsSceneMouseEvent) bool[source]
Handle a QGraphicsScene.mouseReleaseEvent.
- mouseDoubleClickEvent(event: QGraphicsSceneMouseEvent) bool[source]
Handle a QGraphicsScene.mouseDoubleClickEvent.
- contextMenuEvent(event: QGraphicsSceneContextMenuEvent) bool[source]
Handle a QGraphicsScene.contextMenuEvent
- dragEnterEvent(event: QGraphicsSceneDragDropEvent) bool[source]
Handle a QGraphicsScene.dragEnterEvent
Added in version 0.1.20.
- dragMoveEvent(event: QGraphicsSceneDragDropEvent) bool[source]
Handle a QGraphicsScene.dragMoveEvent
Added in version 0.1.20.
- class orangecanvas.document.interactions.DropAction(document, *args, dropHandlers: Sequence[DropHandler] = (), **kwargs)[source]
Bases:
UserInteractionA drop action on the workflow.
- dropHandlers() Iterable[DropHandler][source]
Return an iterable over drop handlers.
- canHandleDrop(event: QGraphicsSceneDragDropEvent) bool[source]
Can this interactions handle the drop event.
The default implementation checks each dropHandler if it
accepts()the event. The first such handler that accepts is selected to be the designated handler and will receive the drop (doDrop()).
- class orangecanvas.document.interactions.DropHandler[source]
Bases:
ABCAn abstract drop handler.
Added in version 0.1.20.
- abstract accepts(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) bool[source]
Returns True if a document can accept a drop of the data from event.
- abstract doDrop(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) bool[source]
Complete the drop of data from event onto the document.
- class orangecanvas.document.interactions.DropHandlerAction[source]
Bases:
ABC- abstract actionFromDropEvent(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) QAction[source]
Create and return an QAction representing a drop action.
This action is used to disambiguate between possible drop actions.
The action can have sub menus, however all actions in submenus must have the DropHandler instance set as their QAction.data().
The actions must not execute the actual drop from their triggered slot connections. The drop will be dispatched to the action.data() handler’s doDrop() after that action is triggered and the menu is closed.
- class orangecanvas.document.interactions.NodeFromMimeDataDropHandler[source]
Bases:
DropHandler,DropHandlerActionCreate a new node from dropped mime data.
Subclasses must override canDropMimeData, parametersFromMimeData, and qualifiedName.
Added in version 0.1.20.
- abstract qualifiedName() str[source]
The qualified name for the node created by this handler. The handler will not be invoked if this name does not appear in the registry associated with the workflow.
- abstract canDropMimeData(document: SchemeEditWidget, data: QMimeData) bool[source]
Can the handler create a node from the drop mime data.
Reimplement this in a subclass to check if the data has appropriate format.
- abstract parametersFromMimeData(document: SchemeEditWidget, data: QMimeData) Dict[str, Any][source]
Return the node parameters based from the drop mime data.
- accepts(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) bool[source]
Reimplemented.
- doDrop(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) bool[source]
Reimplemented.
- shouldActivateNode() bool[source]
Should the new dropped node activate (open GUI controller) immediately.
If this method returns True then the activateNode method will be called after the node has been added and the GUI controller created.
The default implementation returns False.
- activateNode(document: SchemeEditWidget, node: Node, widget: QWidget) None[source]
Activate (open) the node’s GUI controller widget after a completed drop.
Reimplement this if the node requires further configuration via the GUI.
The default implementation delegates to the
WidgetManagerassociated with the document.
- actionFromDropEvent(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) QAction[source]
Reimplemented.
- class orangecanvas.document.interactions.PluginDropHandler(group='orangecanvas.document.interactions.DropHandler', **kwargs)[source]
Bases:
DropHandlerDelegate drop event processing to plugin drop handlers.
Added in version 0.1.20.
- ENTRY_POINT = 'orangecanvas.document.interactions.DropHandler'
The default entry point group
- iterEntryPoints() Iterable[EntryPoint][source]
Return an iterator over all entry points.
- entryPoints() Iterable[Tuple[EntryPoint, DropHandler]][source]
Return an iterator over entry points and instantiated drop handlers.
- accepts(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) bool[source]
Reimplemented.
Accept the event if any plugin handlers accept the event.
- doDrop(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) bool[source]
Reimplemented.
Dispatch the drop to the plugin handler that accepted the event. In case there are multiple handlers that accepted the event, a menu is used to select the handler.