OpenLayers addon : Key pressed Listener

Hi,

I would like to thank Matti Tahvonen for this great addon. It’s very useful !

I’m using your addon and i need to allow user drawing circle zones by clicking shift key or any other key (i mentioned the shift key because it has already a zoom behaviour, i wondered if i can change this behaviour or not). Or can i use the mouse’s right button to draw circle ?

The problem is that users have to click a draw button to change the drawing mode from NONE to CIRCLE and it’s not a good way to do it ! I think allowing users to explore the map by default and drawing when clicking shift button or the mouse’s right button would be much better.

Thanks,
Abdelbaki.

Hi,

I haven’t tried, but I guess you could use shortcut actions to change the drawing mode. Something like this:



		Handler handler = new Handler() {

			ShortcutAction circle = new ShortcutAction(null, KeyCode.O,
					new int[] { ModifierKey.CTRL });

			public void handleAction(Action action, Object sender, Object target) {
				if(action == circle) {
					doStuffToPutToCircleMode();
				}
			}

			public Action[] getActions(Object target, Object sender) {
				return null;
			}
		};
		window.addActionHandler(handler);