Xeno Posted February 8, 2012 Posted February 8, 2012 I'm working with dxDraw now, and I'm trying to make it so you can press a piece of text so it triggers something else. I neally got it to work, but I need it so it works when I click on the dxDrawText, because at the moment, the GUI appears when I click anywhere on the screen. Please help me. dxDrawText ( "Chheseseseses", 050, screenHeight - 530, screenWidth, screenHeight, tocolor ( 0,0,0, 255 ), 5, "sans" ) function news(clickedElement) if (clickedElement) then addEventHandler("onClientRender",rootElement, serverBoxDesign) end end addEventHandler ( "onClientClick", getRootElement(), news )
Paper Posted February 8, 2012 Posted February 8, 2012 You are triggering the event onClientClick, if you don't insert an if statement for check what you've clicked it will show the text always, do like this: function news(clickedElement) if (clickedElement == something) then addEventHandler("onClientRender",rootElement, serverBoxDesign) end end addEventHandler ( "onClientClick", getRootElement(), news ) You want that when you click on something like a text it shows another text? You must repleace "something" in the if whit the text name, and (i think) it will work
drk Posted February 8, 2012 Posted February 8, 2012 lol, you can't replace "something" with the text name. You have to replace with the variable. In this case you have to use an alternative dx text drawing system that you can set a variable to or use gui label ( or other you want ).
Xeno Posted February 8, 2012 Author Posted February 8, 2012 Well I don't want to use a label... And there is a way you can make them clickalbe, I've seen it.
Castillo Posted February 8, 2012 Posted February 8, 2012 The first argument of "onClientClick" is the mouse button pressed, not the world element clicked.
Xeno Posted February 8, 2012 Author Posted February 8, 2012 The first argument of "onClientClick" is the mouse button pressed, not the world element clicked. function news(clickedElement) if (clickedElement == login) then addEventHandler("onClientRender",rootElement, serverBoxDesign) end end addEventHandler ( "onClientClick", down, news ) Error: Bad arguement @ "addEventHandler" [Expected Element at arguement, 2 got nil]
Castillo Posted February 8, 2012 Posted February 8, 2012 You want to detect when click on a GUI element? if so use "onClientGUIClick". function news(_,_,_,_,_,_,_,clickedElement) if (clickedElement == login) then addEventHandler("onClientRender",rootElement, serverBoxDesign) end end addEventHandler ( "onClientClick", root, news )
Castillo Posted February 8, 2012 Posted February 8, 2012 onClientClick doesn't work for DX drawing, you must make your own event. You can use getCursorPosition to compare the position of the DX drawing with the mouse.
Xeno Posted February 8, 2012 Author Posted February 8, 2012 Do you have an example I could use? ( Sorry, I just won't be able to do it.. I Just saw the Wiki lol)
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