~DarkRacer~ Posted June 4, 2013 Share Posted June 4, 2013 is there any event to check if the cursor was pointed/hovered or clicked on a specific dx rectangle ? Link to comment
Moderators IIYAMA Posted June 4, 2013 Moderators Share Posted June 4, 2013 local rectangePos = {{200, 200,400,400}} addEventHandler("onClientRender",root, function() local myTable = rectangePos[1] local XposStart,YposStart,XposEnd,YposEnd = myTable[1],myTable[2],myTable[3],myTable[4] local x,y,,yD,zD = getCursorPosition ( ) end) + https://wiki.multitheftauto.com/wiki/OnClientClick Link to comment
~DarkRacer~ Posted June 4, 2013 Author Share Posted June 4, 2013 Thanks but this code only stores the the rectangle and cursor position where is the 'if statement' to check if the cursor is on the rectangle Link to comment
Moderators IIYAMA Posted June 4, 2013 Moderators Share Posted June 4, 2013 You have the position of the cursor and you have the positions of the rectange, as far I know it isn't that hard to compare them.I haven't said that I finished the code, I just help you creating the basic. It is your job to finish it. Note* it doesn't store a cursor position because it is a local. Link to comment
~DarkRacer~ Posted June 4, 2013 Author Share Posted June 4, 2013 You have the position of the cursor and you have the positions of the rectange, as far I know it isn't that hard to compare them.I haven't said that I finished the code, I just help you creating the basic. It is your job to finish it.Note* it doesn't store a cursor position because it is a local. ok but there's one thing i don't understand .. what are the 4 values in the table?? does it includes the width and height or there're just coords if so.. then witch one is the X and Y ? Link to comment
~DarkRacer~ Posted June 4, 2013 Author Share Posted June 4, 2013 ok i found a way to do it but getCursorPosition() returns an relative coords for the x and y, and dxDrawRectangle only absolute coords. Link to comment
Castillo Posted June 4, 2013 Share Posted June 4, 2013 Easy, just convert it to absolute. function getAbsoluteCursorPosition ( ) if isCursorShowing ( ) then local sx, sy = guiGetScreenSize ( ) local cursorX, cursorY = getCursorPosition ( ) return ( cursorX * sx ), ( cursorY * sy ) end end Link to comment
~DarkRacer~ Posted June 4, 2013 Author Share Posted June 4, 2013 @IIYAMA Thank You! @SolidSnake Thanks bro, i really appreciate it 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