Jump to content

Custom cursor image for a specific GUI element


vx89

Recommended Posts

Hey,

Just wanted to share a nasty little trick to have a custom cursor for a window (should also work with any other gui element):

function getImageReference(imagePath) 
    local staticImage = guiCreateStaticImage(0, 0, 0, 0, imagePath, false) 
    guiSetVisible(staticImage, false) 
    return guiGetProperty(staticImage, "Image") 
end 
  
  
local imgRef = getImageReference("client/img/mouse.png") 
local myWindow = guiCreateWindow( 0, 0, 0.5, 0.4, "Information", true)  -- create a window which has "Information" in the title bar. 
guiSetProperty(myWindow, "MouseCursorImage", imgRef) 
  

Too bad the very root window is not accessible (guiRoot) for guiSetProperty - but probably better for security reasons.

Also, it doesn't seem to be possible to make a click-through full screen window and use a custom cursor, because if you set "MousePassThroughEnabled" for a window property, then it will not catch mouse hovering and you won't get the custom cursor.

But still, maybe this is useful for someone.

Link to comment

Hy vs89,

you can use an image as cursor (and set the original cursor alpha to 0) like in this resource:

[REL] HeroCursor - Client Custom Cursor Management

and in addition you can switch the cursor image if the Events onClientMouseEnter and onClientMouseLeave trigger.

changeCC("normalcursor.png") 
  
addEventHandler( "onClientMouseEnter", myWindow, function() 
     changeCC("windowcursor.png") 
end) 
addEventHandler( "onClientMouseLeave", myWindow, function() 
     changeCC("normalcursor.png") 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...