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:
QObject
Base 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 (
True
by 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
CanvasScene
when 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:
UserInteraction
A 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:
ABC
An 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
,DropHandlerAction
Create 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
WidgetManager
associated with the document.
- actionFromDropEvent(document: SchemeEditWidget, event: QGraphicsSceneDragDropEvent) QAction [source]
Reimplemented.
- class orangecanvas.document.interactions.PluginDropHandler(group='orangecanvas.document.interactions.DropHandler', **kwargs)[source]
Bases:
DropHandler
Delegate drop event processing to plugin drop handlers.
Added in version 0.1.20.
- ENTRY_POINT = 'orangecanvas.document.interactions.DropHandler'
The default entry point group
- 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.