Getting mouse events over GoJS surface


since I upgraded to goJS 1.6.1 document level mouse events don’t work if they happen over the GoJS surface… is this a new thing?.. can it be turned off?.. my guess is goJS marks those events as handled or something… :-S

I have 2 scenarios that suffer from this… one is a context menu that doesn’t hide when you click on goJS surface… and one is dragging and dropping from a “toolbox” that just stops when entering the goJS surface…

both those scenarios used to work fine in 1.5.5… and that upgrade is the only big thing that we changed… as far as I know.


For 1.6 we made some internal changes to event bubbling. Generally, if GoJS uses an event for something, it won’t let that event bubble up to the rest of the page. You can sometimes stop this (or explicitly do it) by setting the e.handled property of InputEvent.

Whats your scenario, exactly?

for the drag and drop one… we use an old version of jstree… and we subscribe to events like this:

        $(document).bind("mousemove", $.vakata.customDnd.drag);
        $(document).bind("mouseup", $.vakata.customDnd.drag_stop);

the mouseup one comes fine… but mousemove doesn’t come when we move over the gojs surface…

for the context menu there is a similar thing but we attach to mousedown… and that doesn’t come for gojs surface either…

if what you say is the issue, and it seems like it would be, is there an option or something in gojs to stop that?

I have some gojs elements that are actionable and handle mouseenter, mouseleave, actiondown etc… is that related?

If you added:

myDiagram.doMouseMove = function() {
  myDiagram.lastInput.bubbles = true;;

Would you get mouse events for the mousemoves?

sorry for the late reply…

yes… that helped!.. kind of… I had to do it like this:

diagram.toolManager.doMouseDown = function () {;
    diagram.lastInput.bubbles = true;

is that ok?.. or will that break something else?


That may lead to issues.

Could you get 1.6.5 (the latest), which has a modification to doMouseMove (but not doMouseDown) and tell me if it fixes your problem, without adding any work-around code? In other words, remember to remove your work-around override functions.

yup… 1.6.5 fixed the problem with mouse move…

but I still have to do that “trick” for mouse down… :frowning:

what kind of issues could doing that generate?.. maybe it’s something I can live with…

It’s somewhat circumstantial. For instance, with that addition, perhaps panning the diagram will also pan the page.

It may be safer to do that only for certain tools, or only when no tool is running, etc. This might be safer, but I haven’t given it a huge amount of thought:

diagram.toolManager.doMouseDown = function () {;
    // only bubble if no specific tool is currently in use
    // (toolManager is the default tool)
    if (diagram.currentTool === diagram.toolManager) diagram.lastInput.bubbles = true;

yup… that does seem to be a bit safer… :slight_smile: