MouseDown event

194 views
Skip to first unread message

Darko Drakulic

unread,
Jul 15, 2013, 6:19:00 PM7/15/13
to jsxg...@googlegroups.com
Hi to all,

I need to call alert function in mouseDown event and it makes a problem when and object is selected. This fiddle is simplification of my problem:


The problem is when point A is clicked. I need solution for this, so if you have any ideas, you are welcome. Is is possible to call mouseUp event from code or something like that?

All the best,
Darko

--

Darko Drakulic
University of East Sarajevo
Department for Mathematics and Computer Science
GeoGebra Institute of East-Sarajevo
da...@geogebra.org (geogebra) 

Mobile phone: +387 65 834 980

Alfred Wassermann

unread,
Jul 16, 2013, 5:31:46 AM7/16/13
to jsxg...@googlegroups.com
You can fire an event like this:

var brdyy = JXG.JSXGraph.initBoard('boxyy',{axis:false, boundingbox: [0, 28, 45, 0]});

brdyy.create("point", [15,15]);

brdyy.on("mousedown", function() {
    var evt = document.createEvent("MouseEvents");
    evt.initEvent("mouseup", true, true);
    document.dispatchEvent(evt);
    alert("click!");
});

This works on non-IE browsers. For a platform independent solution for firing events see e.g.
http://stackoverflow.com/questions/827716/emulate-clicking-a-link-with-javascript-that-works-with-ie

Best wishes,
Alfred



Seth Weiss

unread,
Jul 16, 2013, 5:51:08 AM7/16/13
to jsxg...@googlegroups.com, jsxg...@googlegroups.com
Darko:

on your fiddle
changing mousedown to mouseup


brdyy.on("mouseup", function() {
   alert("click!");
});


works for me in safari, firefox and chrome

hope this helps


seth

michael

unread,
Jul 16, 2013, 6:06:09 AM7/16/13
to jsxg...@googlegroups.com
JSXGraph internal events can be trigger with trigger().


trigger() takes two arguments, first one is an array of the events that will be triggered, second (optional) argument is an array of parameters that will be given to the event handlers.



Michael

Darko Drakulic

unread,
Jul 16, 2013, 10:06:19 AM7/16/13
to jsxg...@googlegroups.com
Thank you Alfred, your solution works.

Michael, your solution still have the same problem - point moves after click.

Seth, I know for that, but I need mouseup event (because for other functionality).

Thank you for all!
Reply all
Reply to author
Forward
0 new messages