KaMeR Posted January 12, 2008 Share Posted January 12, 2008 why the two buttons have same effect when clicking whats wrong? closeButton = guiCreateButton( 0.1, 0.9, 0.8, 0.1, "click here to close", true, windowForm) button = guiCreateButton( 0.7, 0.4, 0.2, 0.1, "test", true, windowForm ) function bClose ( closeButton ) guiSetVisible ( windowForm, false ) showCursor ( false ) end function test( button ) outputChatBox ( "test" ) end addEventHandler ( "onClientGUIClick", getRootElement(), bClose ) addEventHandler ( "onClientGUIClick", getRootElement(), test ) Link to comment
d0c Posted January 12, 2008 Share Posted January 12, 2008 Because you're assigning your onClientGUIClick event handlers to the root element, not the button you want them to react to. That means the handler will be executed whenever any GUI element has been clicked, so the GUI will first be hidden and then you get the "test" output for both buttons. To fix this, use the button you want the handler to react to in addEventHandler: addEventHandler ( "onClientGUIClick", closeButton, bClose ) addEventHandler ( "onClientGUIClick", button, test ) BTW, you should not name function arguments like global variables or the globals will be inaccessible in the function. Link to comment
KaMeR Posted January 12, 2008 Author Share Posted January 12, 2008 already tryed that nothing happend when clicking buttons Link to comment
[email protected] Posted January 12, 2008 Share Posted January 12, 2008 already tryed that nothing happend when clicking buttons check this: viewtopic.php?f=91&t=21370#p268805 For some reason the buttons have issues in the addEventHandler routine. 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