Leaflet Draw Control - Trigger click on Cancel button to cancel drawing of a shape - leaflet

After the user starts drawing a particular shape I need a way to automatically cancel the drawing as if user clicked on the Cancel button that appears beside the selected shape in the draw toolbar.
Pressing the Escape key cancels the draw operation & fires the correct event. So tried to create a js function (see code snippet below) to emulate the pressing of the Escape key.
`function cancelDrawToolbarShape() {
var esc = $.Event("keyup", { keyCode: 27 });
$("document").trigger(esc);
}
`
This did not work.

Related

How to stop brush drag when mouse leaves the chart area

The issue is this:
left-click in the chart area and HOLD the left button
now the brush-drag is active: we can move the mouse around and the area will follow
but when we exit the chart area (e.g. far to the right on the grey area) and then release the mouse button (still on the grey area), the brush-drag mode gets stuck
what I mean is, when you now move the mouse back to the chart area, the brush-drag is still active: i.e. the mouse move will resize the brush area although the left-mouse button is NOT pressed down anymore
this will only stop when you make another click inside the chart area
How can we avoid this?
what I want to happen is that the brush area just selects all the data (until the border of the chart) and then stops: i.e. it should do the same as when I release the mouse button in the chart
So I thought I can just send a mouseup event when the mouse leaves the chart area - but this does not work
I also did not find a suitable action in the echart-docs
Here is a full jsfiddle example and the mouseup event that I tried to send:
const mouseUpEvent = new MouseEvent('mouseup');
var echartsDom = myChart.getDom();
var canceled = echartsDom.dispatchEvent(mouseUpEvent);
This was a bug echarts#10675 that has been fixed in version 4.5.0

WPF MouseEnter does not fire when MouseButton is Pressed

In short: If any mouse button is Pressed when the mouse enters a WPF window, all mouse events are ignored regardless of whether the mouse is captured by any process.
The Challenge
Create two WPF 4.5 projects. In the first one, add a Border with a MouseDown handler. Inside that handler, do everything you can think of to release mouse capture:
this.ReleaseMouseCapture();
element.ReleaseMouseCapture(); // "sender"
Mouse.Capture(null);
while (Mouse.Captured != null)
Mouse.Captured.ReleaseMouseCapture();
ReleaseCapture(); //Win32.ReleaseCapture()
In the other project, add a MouseEnter handler to the default grid that will change its Background.
Start them both up, MouseDown on the border and "drag" to the other window. Until you release the mouse button, the second Window's background will not change.
What's really annoying is that if you stay within the first window, the attempts to "uncapture" the mouse appear to work. Add another element in the first window with a MouseEnter handler, and it will fire just fine. This implies that WPF doesn't know or care about cross-process capture. It just ignores events if any mouse button is in the Pressed state when the mouse first enters an application.
Anyone know if it's possible to have WPF elements respond to mouse events when the mouse was pressed before entering them?

Untoggle all figure toolbar buttons

I want to add a new toggle button to the figure toolbar. When it is clicked, I want to "untoggle" any other buttons that were toggled. E.g, if the "rotation" or "zoom" toggle buttons were pressed, I want to untoggle them and their effect.
Simply getting all their handles does not work, as this does not deactivate their effect.
You should first find all of the children of toolbar. You can do it by the following command (Assuming that currentToggleButton is a handle to current toggle button):
get( get(currentToggleButton,'Parent'),'Children');
Then do the following:
set(children,'State','off');
Of course, you need to return the state of your current button to on.
set(currentToggleButton,'State','on');
By the way, if you are using GUIDE, you can add zoom,rotate and pan as pre-defined tools. In that case, Matlab will handle the toggling automatically.
In order to turn off the effect of zooming/pan/rotation, you can do:
zoom('off')
pan('off')
rotate3d('off')
or you can use another syntax version (as #Eitan also mentions)
zoom off
pan off
rotate3d off

hide cursor in mouse move handler and show it on mouse up

I'm developing a schematic editor, i need to hide the cursor when the middle key is down and moving, and show it again when the mouse up event occurs to implement an user friendly zooming system. The hide and show methods works fine when they are called from outside these event handlers, bud does not work when then called within the event handler!

selecting by mouse clicks instead of press-drag action in MFC

I am quite new to MFC. I am currently using the CrectTracker class of MFC to draw a selection rectangle to select an area on a graphic in MFC based application. However, I would like to do the selection using mouse clicks instead of L button press and drag and release action.
Can somebody point me to an example where the crectracker class can be used to select an area using mouse clicks, first click to start the selection and second to end? Or do I have to implement my own OnLButtonUp actions for this?
Thanks.
You need to implement the MouseMove event.
http://msdn.microsoft.com/en-us/library/3158baat%28v=vs.80%29.aspx
This functions gives you 2 Parameters.
Flag : Here you can check the Left Mouse Button is Clicked
Point : Position of the Mouse cursor.