Demo illustrating use of event handler subscription.
User can draw rectangles, ellipses, or lines. Shape type is selected by pressing corresponding
toggle button. For the sake of simplicity of the demo code, only one instance of shape of each
type is used. User draws a shape by pressing and dragging a mouse.
Each shape type has its own mouse event handler. Only one handler is used at a time.
Handlers are implemented using a simple method MouseEvent => Unit. When switching handlers,
previous handler, if any, is cancelled using a Subscription pattern.
Demo illustrating use of event handler subscription.
User can draw rectangles, ellipses, or lines. Shape type is selected by pressing corresponding toggle button. For the sake of simplicity of the demo code, only one instance of shape of each type is used. User draws a shape by pressing and dragging a mouse.
Each shape type has its own mouse event handler. Only one handler is used at a time. Handlers are implemented using a simple method
MouseEvent => Unit
. When switching handlers, previous handler, if any, is cancelled using aSubscription
pattern.