GoogleCodeArchive / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

PInputEvent needs refactoring #119

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by allain.lalonde on 4 Aug 2009 at 1:30

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 26 Nov 2013 at 9:11