SpoutDev/Spout — Issue #1079: Unmess Keyboard and Mouse handling for Widgets
Author: narrowtux
Created: 2011-11-30 17:20:48+00:00
State: open
Labels: API, Feature Request

Right now, all the handling is done in a single method. If someone wants to do his very own widgets with own handlings he isn't able to do so. Also, it is not possible to cancel the handling of both events.
I'd propose this:
Add callbacks to Control:
-boolean onMouseDown(int x, int y, int button)
-boolean onMouseUp(int x, int y, int button)
-boolean onMouseMove(int x, int y)
-boolean onKeyDown(int key)
-boolean onKeyUp(int key)

If widgets are instanceof Control and in focus, all of the events will get called.
If not, Widgets have to set that they want to listen to mouse moves and keypresses/releases seperately. Mouse moves will only be reported when the mouse is actually over the widget, key press and key releases will be called each time.

All the callbacks have a boolean return value. This is meant to return if the event should be cancelled. If it is cancelled, no further handling will be done.

Widgets have to register for callbacks with Priorities:
-registerForMove(boolean active, Priority priority)
-registerForKeyboard(boolean active, Priority priority)