Status: Accepted
Owner: allain.lalonde
Labels: Type-Enhancement Priority-Medium Effort-High OpSys-All  
Toolkit-Piccolo2D.Java Component-Core Milestone-2.0 Usability

New issue 119 by allain.lalonde: PInputEvent needs refactoring

PInputEvent is a class that behaves differently depending on what kind of  
swing event it is wrapping.

For example, if you try to access the camera on a key event, an error  
occurs, or if you try to use getKeyCode() on a
MouseEvent an exception is thrown.

The caller of the class should definitely not be responsible for tracking  
what methods are valid in their context.  It
makes it much harder to learn the interface.

My suggestion is to refactor the code so that:
1. PInputEvent is an abstract base class
2. Introduce new classes for each kind of Swing Event.  For example,  
MouseEvent would have PMouseEvent, KeyEvent would have
PKeyEvent, etc.
3. add registration methods to PNode that relate to these new events.   
add/removeMouseListener, add/removeKeyListener, etc.
And create new listener interfaces.
4. Modify PInputManager accordingly so that it emits and notifies  
appropriate listeners of the more specific event.

I think this is a sufficiently large change to warrant inclusion in 2.0.

You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:

Piccolo2D Developers Group:

Reply via email to