fsdfdsf Posted February 7, 2015 Share Posted February 7, 2015 I still dnt know,how make a dxbutton and dxEditbox like this plss friends? Link to comment
TAPL Posted February 7, 2015 Share Posted February 7, 2015 'isMouseInPosition' 'onClientClick' 'onClientCharacter' dxDrawImage dxDrawRectangle dxDrawText Link to comment
fsdfdsf Posted February 8, 2015 Author Share Posted February 8, 2015 pleas example guys? Link to comment
Dealman Posted February 8, 2015 Share Posted February 8, 2015 (edited) Read about the functions and events TAPL just provided you thoroughly and you'll be able to figure something out. You can't live on examples all of your life, eh? Give it some time, test things out. Scripting and programming involves a whole lot of trial and error, see what you can come up with and we'll help you from there buddy Just think of it logically, write it down if you think it helps. Say you want to create a button: 1. First you'll need a way to check if the cursor is currently within the area. For this you can use Castillo's function isMouseInPosition (I renamed it to isCursorWithin). 2. Secondly, once you have a way to check if the cursor is within the button's area, you'll need to detect whenever the mouse is clicked. onClientClick should do the trick! Remember to read about the parameters it passes to your function. 3. Thirdly, use those together and use outputChatBox to see if it works. It should only output a message if you click within the button's area. Editboxes are a bit tougher to make, so start with the button. Edited February 8, 2015 by Guest Link to comment
fsdfdsf Posted February 8, 2015 Author Share Posted February 8, 2015 thx man,i tryed alot, all times i failed,just give me example and i'll continue pls Link to comment
Dealman Posted February 8, 2015 Share Posted February 8, 2015 Updated my previous reply with some hints, should help you make a button. Link to comment
fsdfdsf Posted February 8, 2015 Author Share Posted February 8, 2015 ty alot man, i hve this local x, y = guiGetScreenSize() bindKey("F2", "down", function() start = getTickCount() addEventHandler("onClientRender", getRootElement(), logo) end) function logo() showCursor(true) local showing = isCursorShowing () if showing then -- if the cursor is showing local screenx, screeny, worldx, worldy, worldz = getCursorPosition() jaja = dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) ) end destroyElement(jaja) end addEventHandler ( "onClientClick", getRootElement(), logo ) give me an example from you,idk how to puzzle the codes but example with castillo code not getCursorPosition Link to comment
TAPL Posted February 8, 2015 Share Posted February 8, 2015 Example: function isMouseInPosition ( 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 addEventHandler("onClientRender", root, function() local imgX, imgY, imgWidth, imgHeight = 50, 50, 200, 200 buttonHover = isMouseInPosition(imgX, imgY, imgWidth, imgHeight) dxDrawImage(imgX, imgY, imgWidth, imgHeight, buttonHover and "myImage2.png" or "myImage.png", tocolor(255, 255, 255)) end) addEventHandler("onClientClick", root, function(button, state) if button == "left" and state == "down" then if buttonHover then outputChatBox("Button clicked!") end end end) Link to comment
Dealman Posted February 8, 2015 Share Posted February 8, 2015 Also, dxDrawText, dxDrawRectangle and dxDrawLine do not return elements. 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