4.2. AbstractTool

4.2.1. Synopsis

4.2.1.1. Functions

4.2.1.2. Virtual functions

4.2.2. Detailed Description

Abstract tool class that provides overridable methods to determine custom tools. Every overridable method must be implemented.
class mocha.tools.AbstractTool([action=NULL])
Parameters:action (PySide2.QtWidgets.QAction) – A PySide.QtGui.QAction instance associated with the tool.

Creates a custom tool instance. action will be added automatically to mocha tool bar and tool menu if it is passed in. If the argument is None, an associated action will be created anyway, but will not be added to mocha tool bar and tool menu and be available from action(). Don’t create the instance manually. Mocha backend creates the instance upon project opening and destroys it upon project closing. Please note that you must redefine __init__ method, as mocha passes a mocha.project.Project instance as the single argument.

Example:

class MyTool(AbstractTool):
   def __init__(self, project_instance):
      ...
      action = QAction()
      ...
      AbstractTool.__init__(self, action)
   ...
AbstractTool.action()
Return type:PySide2.QtWidgets.QAction

Returns associated PySide.QtGui.QAction instance.

AbstractTool.on_activate()

Implements a handler on the tool activation event.

AbstractTool.on_deactivate()

Implements a handler on the tool activation event.

AbstractTool.on_mouse_move(event)
Parameters:event (mocha.tools.InputEvent) – Input event instance.

Implements a handler on the mouse move event.

AbstractTool.on_mouse_press(event)
Parameters:event (mocha.tools.InputEvent) – Input event instance.

Implements a handler on the mouse press event.

AbstractTool.on_mouse_release(event)
Parameters:event (mocha.tools.InputEvent) – Input event instance.

Implements a handler on the mouse release event.