Jump to content

On mouse enter a interface change it color?


Recommended Posts

You can use this simple function:

function isMouseInPosition ( x, y, width, height ) 
    if ( not isCursorShowing ( ) ) then 
        return false 
    end 
  
    local sx, sy = guiGetScreenSize ( ) -- Get the player screen resolution 
    local cx, cy = getCursorPosition ( ) -- Get the cursor position 
    local cx, cy = ( cx * sx ), ( cy * sy ) -- Convert relative positions to absolute 
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then 
        return true 
    else 
        return false 
    end 
end 

Example:

addEventHandler ( "onClientRender", root, 
    function ( ) 
        local color = tocolor ( 0, 0, 0 ) 
        if isMouseInPosition ( 200, 200, 50, 50 ) then 
            color = tocolor ( 255, 0, 0 ) 
        end 
        dxDrawRectangle ( 200, 200, 50, 50, color ) 
    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...