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, parent=None, deleteOnEnd=True)[source]

Bases: PyQt5.QtCore.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 QObject

  • deleteOnEnd (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()[source]

Start the interaction. This is called by the CanvasScene when the interaction is installed.

Note

Must be called from subclass implementations.

end()[source]

Finish the interaction. Restore any leftover state in this method.

Note

This gets called from the default cancel() implementation.

cancel(reason=5)[source]

Cancel the interaction with reason.

isFinished()[source]

Is the interaction finished.

isCanceled()[source]

Was the interaction canceled.

cancelReason()[source]

Return the reason the interaction was canceled.

mousePressEvent(event)[source]

Handle a QGraphicsScene.mousePressEvent.

mouseMoveEvent(event)[source]

Handle a GraphicsScene.mouseMoveEvent.

mouseReleaseEvent(event)[source]

Handle a QGraphicsScene.mouseReleaseEvent.

mouseDoubleClickEvent(event)[source]

Handle a QGraphicsScene.mouseDoubleClickEvent.

keyPressEvent(event)[source]

Handle a QGraphicsScene.keyPressEvent

keyReleaseEvent(event)[source]

Handle a QGraphicsScene.keyPressEvent

contextMenuEvent(event)[source]

Handle a QGraphicsScene.contextMenuEvent

dragEnterEvent(event)[source]

Handle a QGraphicsScene.dragEnterEvent

New in version 0.1.20.

dragMoveEvent(event)[source]

Handle a QGraphicsScene.dragMoveEvent

New in version 0.1.20.

dragLeaveEvent(event)[source]

Handle a QGraphicsScene.dragLeaveEvent

New in version 0.1.20.

dropEvent(event)[source]

Handle a QGraphicsScene.dropEvent

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.UserInteraction

A 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()).

dragEnterEvent(event)[source]

Handle a QGraphicsScene.dragEnterEvent

New in version 0.1.20.

dragMoveEvent(event)[source]

Handle a QGraphicsScene.dragMoveEvent

New in version 0.1.20.

dragLeaveEvent(even)[source]

Handle a QGraphicsScene.dragLeaveEvent

New in version 0.1.20.

dropEvent(event)[source]

Handle a QGraphicsScene.dropEvent

New in version 0.1.20.

class orangecanvas.document.interactions.DropHandler[source]

Bases: abc.ABC

An abstract drop handler.

New 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.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.DropHandlerAction

Create 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.

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) PyQt5.QtWidgets.QAction[source]

Reimplemented.

class orangecanvas.document.interactions.PluginDropHandler(group='orangecanvas.document.interactions.DropHandler', **kwargs)[source]

Bases: orangecanvas.document.interactions.DropHandler

Delegate 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.

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.