Posts: 19
Threads: 6
Joined: Oct 2011
Reputation:
0
11-04-2011, 09:46 PM
(This post was last modified: 11-04-2011, 09:54 PM by JRodman.)
No matter how I declare the handler for the MouseUp event on children within the zoompanel, the event never fires. It does on right mouse button and if I remove the zoompanel from around it. I even went as far as attaching to the event manually using AddHandler and using the "handledEventsToo" option. Any thoughts on why this is happenning?
To elaborate just a bit more, I have a zoompanel with a canvas inside it. The canvas is loaded with content dynamically at runtime that want to capture all mouseup events from every child. The canvas itself is not being clicked. When I add the handler to the canvas, it never fires. The content within the canvas should be firing the event, and they do when they are not within the zoompanel. They bubble up to the canvas as they should in that case. What is the zoompanel doing that would prevent this from working?
Posts: 736
Threads: 8
Joined: Sep 2009
Reputation:
41
When ZoomPanel is active, it captures the mouse events to handle zooming and panning.
To get left button events you need to deactivate the ZoomPanel by setting its ZoomMode to None. If you are using ZoomController this mode is set when the current mode is deactivated - for example if currently move mode is activated (the first button) than the ZoomMode is set to None when the user clicks again on Move button.
To see more details about how to do this please see the PainterSample that comes with ZoomPanel - it is using mouse events on the Canvas inside ZoomPanel to draw on the canvas with the mouse.
If you do not want to put the ZoomPanel's ZoomMode to None, you can subscribe to PreviewMouseLeftButtonDown, PreviewMouseLeftButtonUp, etc. events and get the events before ZoomPanel will get them. In the handler you can can decide if you want to process the event by yourself or pass it to ZoomPanel. If you handle the event by yourself, than set the e.Handled in the EventArgs to true to prevent passing the event further to ZoomPanel.
A similar approach (using Preview mouse events) is used in the Multi mouse buttons sample that comes with ZoomPanel.
When ZoomMode on ZoomPanel is not set to None
Andrej Benedik
Posts: 19
Threads: 6
Joined: Oct 2011
Reputation:
0
11-10-2011, 09:14 PM
(This post was last modified: 11-10-2011, 10:50 PM by JRodman.)
I dont want to have to turn off the zoommode because I still need to be able to pan. If I attach a preview event handler to the container around the zoompanel or the zoompanel iteself, the event does not tell me which item was actually clicked. Its always the zoompanel. If I attach handlers directly to the items within the zoompanel, they never fire.
Is there a possibility of allowing these events to bubble instead of cancelling them? Maybe add your own implementation of them?