How can I catch mouse drag events in a Dashcode widget?
-
30-09-2019 - |
Question
I have an OSX widget written using Dashcode.
Currently any mouse drag event causes the entire widget to move on the desktop.
I wish to be able to click and drag within a canvas on that widget, but I don't seem to be able to prevent the OSX dashboard from moving the entire widget instead.
I'm already capturing mouse movements quite happily, but the click/drag combo is defeating me.
Solution
I've apparently found the answer, here in the Apple Developer site.
Put a -apple-dashboard-region:
style on the div
that you want to have receive drag events instead of dragging the widget, e.g.:
#canvas {
-apple-dashboard-region: dashboard-region(control rectangle 4px 4px 4px 4px);
}
EDIT - this works - I can now capture onMouseMove()
events when when the mouse button is pressed.
One thing I can't (yet) do is the equivalent of IE's setCapture()
, where mouse movement events continue to be passed to the application even when the drag extends beyond the area of the widget.