Get mouse click point before context menu opens

  • Hi.

    I use the HTML5 viewer (krpano 1.18.5) and have a context menu option for adding a hotspot.

    Code
    <contextmenu>
      <item name="addHotspotMenuItem" caption="Add hotspot" onclick="js(createHotspot())"/>
    </contextmenu>

    In my JavaScript file I have a function to handle the hotspot creation.

    Code
    function createHotspot() {
        var krpano = document.getElementById("krpanoViewer");
     
        var mx = krpano.get("mouse.x");
        var my = krpano.get("mouse.y");
        var pt = krpano.screentosphere(mx, my);
     
        window.external.HotspotCreated(pt.x, pt.y);
    }

    The problem is that the mouse point is the where the mouse is at the moment that the context menuitem is clicked.
    I need to get the point where the right-click was as this should be the hotspot point.
    How is this best done?

    A related question.
    In addition to a using context menu for adding a hotspot it would be a nice feature to use a double-click event for adding the hotspot. Is this possible 'out-of-the-box' or is a plugin necessary for handling double-click events?

    Thanks.

    Best regards
    Dan

  • Hi,

    I need to get the point where the right-click was as this should be the hotspot point.
    How is this best done?

    Good question and idea - there is currently no information or API about that, but I will think about something of the next releases (ideas for how to provide that information are welcome ;-)).


    In addition to a using context menu for adding a hotspot it would be a nice feature to use a double-click event for adding the hotspot. Is this possible 'out-of-the-box' or is a plugin necessary for handling double-click events?

    Double click events are currently not supported out-of-the-box.

    Best regards,
    Klaus

  • Hi,

    i would use a keycode for this.
    So when you press H, put a new hotspot on the mouse location.
    Or maybe.
    Use the/a 'gaze'.
    When right click, select add hotspot and then the 'little cross appears center screen (gaze) So then you can turn and define the location with a second menu option like 'set hotspot here' or keystroke. and the hotspot will be added at that place.

    Or maybe: i can imagine that at the moment you do right click there is something that triggers the context menu to show, and position. I guess you only need the catch of that moment.
    When possible, it would be the best i think to store the ath/atv of mouse of that moment in some vars before the context menu is shown.. and use them when add hotspot is selected.
    (? could be nonsense or not possible of course)
    *blink*
    *g*

    Tuur *thumbsup*

  • Hi,

    just as quick note - the next version (1.19-pr4) will provide 'mouse.downx' and 'mouse.downy' variables and there the position of the last mouse button press (for left and right mouse buttons) will be stored.

    Then doing such add hotspot via the contextmenu will be possible.

    Best regards,
    Klaus

  • Thanks for the suggestions (and sorry for the late reply).

    As Tuur suggested I'm using a key event for this. Pressing the 'h' or 'H' key will create a hotspot.
    I'm also using a double-click event (2 click events within a certain time).

    Code
    <events name="addHotspotEvent"
            onclick="js(panoramaClicked())"
            onkeyup="js(panoramaKeyed())" />

    Excellent news about the new variables *thumbsup* , I will be looking forward to it.


    Best regards
    Dan

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!