TheSmart Posted June 20, 2015 Share Posted June 20, 2015 Hello guys! today i need little help im making dx help panel but i don't know how to make dxDrawRectangle button can anybody can tell me how i can do it? Link to comment
Walid Posted June 20, 2015 Share Posted June 20, 2015 Hello guys! today i need little help im making dx help panel but i don't know how to make dxDrawRectangle button can anybody can tell me how i can do it? All what you need is -- Functions dxDrawRectangle() -- Events onClientClick onClientRender Link to comment
Dealman Posted June 20, 2015 Share Posted June 20, 2015 It's rather simple, you check if the cursor's position is within the rectangle. You take the starting X position of the rectangle and add the width of the rectangle to that. Repeat the process with the starting Y position, and then add the height of the rectangle. This way, you'll check if the cursor is within the rectangle, then you can use onClientClick to detect if the left-mouse button was clicked while inside the rectangle. Or you can use a utility function such as this one; function isCursorWithin(x, y, width, height) if(not isCursorShowing()) then return false; end local sx, sy = guiGetScreenSize(); local cx, cy = getCursorPosition(); local cx, cy = (cx*sx), (cy*sy); if(cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then return true; else return false; end end Link to comment
TheSmart Posted June 20, 2015 Author Share Posted June 20, 2015 thnx guys i will try it and i will post code if something wrong with it. Link to comment
xXMADEXx Posted June 21, 2015 Share Posted June 21, 2015 (edited) While you're at it, you should check out the dxGUI system, but it's not complete yet. Edited July 3, 2015 by Guest Link to comment
TheSmart Posted June 21, 2015 Author Share Posted June 21, 2015 While you're at it, you should check out the dxGUI[/wiki] system, but it's not complete yet. but i don't know how to use it Link to comment
darhal Posted July 3, 2015 Share Posted July 3, 2015 function onClick(x, y, absX, absY) if isCursorWithin(absX, absY, width, height) then -- width , height are width height of dx draw (text / rectangle) -- do some codde end end addEventHandler("onClientClick", root, onClick) function isCursorWithin(x, y, width, height) if(not isCursorShowing()) then return false; end local sx, sy = guiGetScreenSize(); local cx, cy = getCursorPosition(); local cx, cy = (cx*sx), (cy*sy); if(cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then return true; else return false; end end 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