GM:S 1.4 Setting mouse position

Discussion in 'Programming' started by Siolfor the Jackal, Mar 8, 2019.

  1. Siolfor the Jackal

    Siolfor the Jackal Member

    Jun 21, 2016
    I have two circles I draw on the screen based on the x/y values I store in selection[]
    The active one moves with the mouse whilst the other stays in it's current position.
    When I press tab it toggles which circle is the active circle.
    Since they are controlled by the mouse I want to move the mouse position to the new active circle's position when I change which one is active so that the inactive circle doesn't teleport to the other circle's position when I toggle it.
    Using display_mouse_set() or window_mouse_set() doesn't work because they seem to ignore the scaling of my surface when it's not at it's native size(My surface is 1920x1080 scaled to fit my laptop's 1366x768 resolution).

    So is there another function I'm missing here or do I need to do some maths when moving the mouse?

        primary = !primary;
        display_mouse_set(selection[primary, 0], selection[primary, 1]);
    selection[primary, 0] = mouse_x;
    selection[primary, 1] = mouse_y;
  2. Relic

    Relic Member

    Jun 27, 2017
    Think it will require maths.... or if the view camera never moves, you could (also) store the x and y values returned by window_mouse_get_x/y. Then set the mouse x and y using window_mouse_set() on toggle.
    Siolfor the Jackal likes this.
  3. Siolfor the Jackal

    Siolfor the Jackal Member

    Jun 21, 2016
    Oh that sounds a bit clever. At the moment the view doesn't move, so that could work.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice