Details
-
New Feature
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.7.4
-
None
-
None
Description
Currently I have to use add(Action|Mouse)Listener if I want to register a action/mouse listener to a component. It would be great if Groovy support 'addAction' and 'addActions' methods that will cleverly register any kind of EventListener to a component without a need to call methods related to it (pre configured via Groovy DSL).
So this is what I basically do in my swing projects:
// Add addAction syntax to java.awt.Component Component.metaClass."addAction" = { action -> if (action instanceof MouseListener) addMouseListener(action); else addActionListener(action); } // Add addActions syntax to java.awt.Component Component.metaClass."addActions" = { actions -> for (def action: actions) addAction(action); }