Skip to content
Thomas edited this page Dec 24, 2019 · 5 revisions

Mouse in General

Uiz has some controlling mouse scripts. Some of these scripts are called every step for "obj_uiZ_" objects. They make sure that when the mouse hovers over an object, that only the frontmost object is selected to receive a signal that says "Hey, you the mouse is on you!".

Normally, we would have a mouse check in every object without uiz, and we would put the mouse over it, the object could run some code. This works for all objects individually. But if we have 2 objects overlapping each other, both objects might fire an event if the mouse is over it, while the user only intended one to be pressed. Uiz eliminates this problem by checking depth.

There are four global variables: "global.mouseoverobject", "global.mouseoverframe", "global.mouseoverwindow" and "global.mouseover".

  • The "global.mouseover" variable works for all uiz objects and returns the one with the lowest depth at the place of the mouse.
  • The "global.mouseoverframe" variable works only for frames and returns the one with the lowest depth at the place of the mouse.
  • The "global.mouseoverwindow" variable works only for windows and returns the one with the lowest depth at the place of the mouse.
  • The "global.mouseoverobject" variable works for all uiz objects except frames and returns the one with the lowest depth at the place of the mouse.
  • The normal mouseover variable is going to be the most useful to you, and is recommended to use in normal objects.

Common checks

Almost every uiz object has an uiz_mouse_docheck() script in its User Defined 1 Event. This script contains all of the important checks to be done for the mouse. This script has been put into an event for legacy reasons, and so that custom code can be written for when the mouse should or shouldn't be handled by your object.

Also a lot of object have the code "kmouseover=uiz_mouse_isonobject_leftcheck(id)" in their normal step event which gives a the objects a general variable to use in other scripts.

  • A kmouseover of uiz_nomouse=0 means no mouse.
  • A kmouseover of uiz_mouseover=1 means the mouse hovers over the object.
  • A kmouseover of uiz_mouseclick=2 means the mouse hovers over the object and the left mouse button is being held.
  • A kmouseover of uiz_mousepressed=3 means the mouse hovers over the object and the left mouse button has just been pressed.
  • A kmouseover of uiz_mousereleased=4 means the mouse hovers over the object and the left mouse button has just been released.

freezing the mouse

You have to be EXTEMELY careful when freezing the mouse, not correctly unfreezing it can cause issues like the mouse not working anymore.

Sometimes and object needs to keep a hold of the mouse, even is the mouse is not over the object anymore. For example, sliding a slider all the way to the right might result in the mouse not being over the slider anymore. However in this example you would still want your slider to be in "move with the mouse"-mode. For this you need "mouse freezing".

Using uiz_mouse_freeze() (or setting the global.mousefrozen variable to true) removes all uiz mousechecks and makes sure that the "global.mouseover" variables aren't changed anymore. No uiz object (except the caller of _freeze()) will react to the mouse anymore.
The mouse needs to be unfrozen by calling uiz_mouse_unfreeze() (or by setting global.mousefrozen to false) when you're done.

If you have a hard time correctly unfreezing the mouse, or just want to be very sure, you can use "uiz_setmousesafety()". This script needs to be called every step while the mouse should be frozen, and if it isn't called anymore then the mouse will automatically unfreeze. This safety feature will generate a warning and it is recommended that you fix your code instead of relying on this last resort.
Not calling the script at all will not result in your mouse being automatically unfrozen, only after calling this script once you need to keep calling if every step for the duration of your mouse freeze.

Custom mouse sprites

Uiz sometime needs to change the mouse to something like a hand when the mouse hovers over a button. However, in your game you might have different sprites for your mouse. Therefore the script uiz_set_cursor(constant) was made. It takes the same constants such as "window_set_cursor" (refer to game maker manual).
You can set a type of sprite for each constants using: global.uiz_cr_constanct_name.
Uiz reset the mouse to cr_default in the beginning of every step. See uiz_set_cursor(constant) for more info.

Wiki pages

🏑Home / General
πŸ“ƒTutorials
πŸ‘ͺ Parent
↕️ Positioning
πŸ›  Fixing & Updating
πŸ• Depth
πŸ“ƒ Templates and Examples
πŸŒ† Background
πŸ“‡ Structures
🎈 Objects

obj_uiZ_3waybutton
obj_uiZ_button
obj_uiZ_checkbox
obj_uiZ_clock
obj_uiZ_colorbox
obj_uiZ_cover
obj_uiZ_drawdslist obj_uiZ_dropdown
obj_uiZ_easybutton
obj_uiZ_frame
obj_uiZ_framescrollbar
obj_uiZ_functionbar
obj_uiZ_gradientsquare
obj_uiZ_gradientroundrect
obj_uiZ_gridlist
obj_uiZ_huesquare
obj_uiZ_loadingbar
obj_uiZ_loadingcircle
obj_uiZ_menubutton
obj_uiZ_mousemenu
obj_uiZ_radiobox
obj_uiZ_rotator
obj_uiZ_slider
obj_uiZ_scrollbar
obj_uiZ_slider_2col
obj_uiZ_slickslider
obj_uiZ_slideframe
obj_uiZ_sprbutton
obj_uiZ_spriteanimationbutton
obj_uiZ_spritecounter
obj_uiZ_stringbox
obj_uiZ_sliderstruct
obj_uiZ_surfacecanvas
obj_uiZ_sprite
obj_uiZ_square
obj_uiZ_squarebutton
obj_uiZ_swipicon
obj_uiZ_switch
obj_uiZ_tabslider
obj_uiZ_tabs
obj_uiZ_treelist
obj_uiZ_text
obj_uiZ_text_background
obj_uiZ_textarea
obj_uiZ_valuebox


🎈 Your own objects
🚫 Destroy
🐭 Mouse
πŸ’» Windows (uiz)
🌌 Animations
❓ General
πŸ“’ Numbers
πŸ“’ Strings
✏️ Draw
🚩 Popup
πŸ“‚ Files
πŸ’» Windows (os)
Clone this wiki locally