vx89 Posted February 28, 2015 Share Posted February 28, 2015 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
launemax Posted February 28, 2015 Share Posted February 28, 2015 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
vx89 Posted February 28, 2015 Author Share Posted February 28, 2015 Hey, Yep, I read about that topic, and this was what triggered me to find alternative method (to actually override the cursor, not try to emulate own cursor). Was just looking into it for fun. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now