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: Optional[PyQt5.QtCore.QObject] = None, deleteOnEnd: bool = True)[source]
Bases:
PyQt5.QtCore.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()
- finished()
- ended()
- canceled()
- 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: PyQt5.QtWidgets.QGraphicsSceneMouseEvent) bool[source]
Handle a QGraphicsScene.mousePressEvent.
- mouseMoveEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent) bool[source]
Handle a GraphicsScene.mouseMoveEvent.
- mouseReleaseEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent) bool[source]
Handle a QGraphicsScene.mouseReleaseEvent.
- mouseDoubleClickEvent(event: PyQt5.QtWidgets.QGraphicsSceneMouseEvent) bool[source]
Handle a QGraphicsScene.mouseDoubleClickEvent.
- contextMenuEvent(event: PyQt5.QtWidgets.QGraphicsSceneContextMenuEvent) bool[source]
Handle a QGraphicsScene.contextMenuEvent
- dragEnterEvent(event: PyQt5.QtWidgets.QGraphicsSceneDragDropEvent) bool[source]
Handle a QGraphicsScene.dragEnterEvent
New in version 0.1.20.
- dragMoveEvent(event: PyQt5.QtWidgets.QGraphicsSceneDragDropEvent) bool[source]
Handle a QGraphicsScene.dragMoveEvent
New in version 0.1.20.
- class orangecanvas.document.interactions.DropAction(document, *args, dropHandlers: Sequence[orangecanvas.document.interactions.DropHandler] = (), **kwargs)[source]
Bases:
orangecanvas.document.interactions.UserInteractionA drop action on the workflow.
- dropHandlers() Iterable[orangecanvas.document.interactions.DropHandler][source]
Return an iterable over drop handlers.
- canHandleDrop(event: PyQt5.QtWidgets.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:
abc.ABCAn abstract drop handler.
New in version 0.1.20.
- class orangecanvas.document.interactions.DropHandlerAction[source]
Bases:
abc.ABC- abstract actionFromDropEvent(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) PyQt5.QtWidgets.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:
orangecanvas.document.interactions.DropHandler,orangecanvas.document.interactions.DropHandlerActionCreate a new node from dropped mime data.
Subclasses must override canDropMimeData, parametersFromMimeData, and qualifiedName.
New 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.
- 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.
- class orangecanvas.document.interactions.PluginDropHandler(group='orangecanvas.document.interactions.DropHandler', **kwargs)[source]
Bases:
orangecanvas.document.interactions.DropHandlerDelegate drop event processing to plugin drop handlers.
New in version 0.1.20.
- ENTRY_POINT = 'orangecanvas.document.interactions.DropHandler'
The default entry point group
- iterEntryPoints() Iterable[importlib_metadata.EntryPoint][source]
Return an iterator over all entry points.
- entryPoints() Iterable[Tuple[importlib_metadata.EntryPoint, orangecanvas.document.interactions.DropHandler]][source]
Return an iterator over entry points and instantiated drop handlers.