Adding modal behavior
In user interfaces, the term modal designates a sub-window or widget that takes all the user interaction for itself, until the operation is ended explicitly.
Usually, operators are designed to return to the main application immediately. If we don’t want that, they should be added to the window manager’s modal handlers.
The operator is then considered modal and will listen to the user inputs until it’s closed manually.
We can make PunchClock
modal and use mouse movement to set our clock. Modal operators have two requirements:
invoke
adds the operator to the handlers and returns'RUNNING_MODAL'
.modal
is implemented and returns'RUNNING_MODAL'
. It returns'FINISHED'
when a user ends it, or'CANCELLED'
to exit with no changes.
We will start to implement the modal execution by changing invoke
and its return value.
Adding the operator to the modal handlers
Instead of passing...