1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 window_set_cursor only works with last instance

Discussion in 'Programming' started by Gamebot, Nov 11, 2019.

  1. Gamebot

    Gamebot Member

    Joined:
    Jul 3, 2016
    Posts:
    191
    I had thought that window_set_cursor was like a global which changes whenever you tell it too. It does for the most part except it only seems to change with the last instance. I tried two, then three, and four instances with each only the last instance will run the window_set_cursor code.

    Oddly enough though all other relevant code before and after the changes happen. See here where I "divided" my box into 9 sections called setsize (for changing sizes and dragging). Sorry if it doesn't come out clear this time.


    nodes box all.png

    The left section, with three instances shows that the over and drag code get executed by the black box border however only the last instance changes to the drag hand. The right two single boxes show that my setsize or area where the mouse hits is working but not the cursor code except again the last instance. Here's the main code im currently using:

    scr_get_handle();
    Code:
    var pix = 4;
    
    // if we are over any instance of obj_box exit so we don't change size accidentally when mouse is over both.
    if (obj_box.mouse_over = true)
    {setsize = 0; window_set_cursor(cr_arrow);}
    
    // Over top left corner. Movement Hor left and Vert up (-x , -y)
    else if (point_in_rectangle(mouse_x, mouse_y, x - pix, y - pix, x + pix, y + pix))      
    {setsize = 1; window_set_cursor(cr_size_nwse);}
    
    // Over top but not in corners. Movemnent Vert up only (x , -y)
    else if (point_in_rectangle(mouse_x, mouse_y, x + pix, y - pix, x + wid - pix, y + pix))      
    {setsize = 2; window_set_cursor(cr_size_ns);}
    
    // Top right corner. Movement Vert up and Hor right. (+x , -y)
    else if (point_in_rectangle(mouse_x, mouse_y, x + wid - pix, y - pix, x + wid + pix, y + pix))
    {setsize = 3; window_set_cursor(cr_size_nesw);}
    
    // Left of box not in corners. Movement Hor left only. (-x , y)
    else if (point_in_rectangle(mouse_x, mouse_y, x - pix, y + pix, x + pix, y + hei - pix))
    {setsize = 4; window_set_cursor(cr_size_we);}
    
    // Right of box not in corners. Movement Hor Right only. (+x , y)
    else if (point_in_rectangle(mouse_x, mouse_y, x + wid - pix, y + pix, x + wid + pix, y + hei - pix))
    {setsize = 5; window_set_cursor(cr_size_we);}
    
    // Left bottom corner. Movement Hor left and vert down. (-x , +y)
    else if (point_in_rectangle(mouse_x, mouse_y, x - pix, y + hei - pix, x + pix, y + hei + pix))
    {setsize = 6; window_set_cursor(cr_size_nesw);}
    
    // Bottom of box. Movement vert down only. (x , +y)
    else if (point_in_rectangle(mouse_x, mouse_y, x + pix, y + hei - pix, x + wid - pix, y + hei + pix))
    {setsize = 7; window_set_cursor(cr_size_ns);}
    
    // Bottom right corner. Movement Hor right and vert down. (+x , +y)
    else if (point_in_rectangle(mouse_x, mouse_y, x + wid - pix, y + hei - pix, x + wid + pix, y + hei + pix))
    {setsize = 8; window_set_cursor(cr_size_nwse);}
    
    else {setsize = 0; window_set_cursor(cr_arrow);}
    Also I did try changinging all steps and draw events just to see if it would make a difference. None. Any thoughts appreciated.
     
    Last edited: Nov 11, 2019
  2. Gamebot

    Gamebot Member

    Joined:
    Jul 3, 2016
    Posts:
    191
    [ UPDATE ]

    It seems the last else statement is the issue. If I take that line of code out...everything seems to work fine except the fact that the cursor never changes back. Also I tried putting the window_set_cursor into an alarm with one step difference (thinking about how window_center works) that didn't help either. Back to the drawing board I guess.

    I'm almost wondering if it has something to do with changing specifically to the arrow and vicde versa. I did try to use default also but no luck.
     

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