-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DragTool mouse down event handling #268
Comments
The That said, the You may find that there are already tools in Chaco and Enable which do what you want, or close to what you want, (eg. for the drag operation to move an object, use |
Hi, Thanks for you swift response. I have implemented all methods, |
The Can you provide a snippet of code that illustrates your problem? |
Hi I think I have figured it out, but I still need some help. I compared our code to one of the examples, and we are using a PanTool, with drag_button=left, thus the PanTool takes the event. Removing the PanTool made it work as it should. I then enabled the PanTool again and tried setting the modifier_key of the DragTool to 'alt' so I can use them together, but this does not work, the PanTool takes the mouse down event anyhow I have a image plot, to which I append a PanTool. Then I plot several line plots on top of the image plot, and attach my LineMoveTool. I also have a ZoomTool with drag_button=right Any ideas to how this can be made to work? |
I tried setting the drag_button of the PanTool in the example (https://github.com/enthought/chaco/blob/master/examples/demo/edit_line.py) to right, and playing around with the order of the two tools, but it seems like the PanTool takes the event anyhow. Setting the modifier_key of the DragTool makes no difference |
The modifier key trait isn't hooked up by default - and it probably should be (but there are issues with the current implementation enthought/enable#90). For an example of how to handle modifier keys in your subclass, see the ValueDragTool above. As far as https://github.com/enthought/chaco/blob/master/examples/demo/edit_line.py goes, it is working for me as expected: the In terms of adding it to your plot, I would add your tool first, then the I feel like I am missing some important information related to your |
I get the edit_line.py example to work correctly, but if I set drag_button to left in the PanTool, the pan tool always handles the event, no matter what order I add them the plot. My LineMoveTool is very similar to the tool in edit_line.py. In the ValueDragTool, the tool consumes the drag button down event in case the drag button is clicked and the tool says it is draggable, while DragTool never consumes this event. Why the difference? I'll try to restructure my overlays and tools, and see what I can get from the ValueDragTool. Maybe I'll just have to implement my own tool from bottom up to get the functionality I am seeking. What I want is: If I click on one of the lines in the plot, my MoveLineTool should be invoked, but if I click and dont hit any lines, I would like the PanTool to be invoked. I guess my LineMoveTool then has to consume the event in the same way as the ValueDragTool does? |
I now see that component sends the event to all tools, even though one tool has consumed the event, i.e. set handled to True. But if a line is clicked, I can set my LineMoveTool to the active tool in the component, then this tool will have priority over events. Should I just set the _active_tool attribute in the component or is there a more proper way of doing this? |
When trying to use DragTool, dragging will not occur unless I also implement my own normal_left_down function:
Unless I implement this method, the
left_down
attribute of the subsequent mouse move events will be False, and dragging will not be handled correctly by the DragTool. Is it correct that I have to implement this extra handling to make it work? And what is the dependency of theMouseEvent.left_down
attribute to previously handled events?Also the DragTool does not use the modifier keys for anything.
The text was updated successfully, but these errors were encountered: