bmat Posted May 11, 2010 Share Posted May 11, 2010 (edited) Hello! I've got a problem. I making GUI now and this GUI doesn't work good. I want to make a button, which will close the window, but this not working good. This is code: function Internet() local screenWidth, screenHeight = guiGetScreenSize() browser = guiCreateWindow(50, 50, screenWidth-100, screenHeight-100, "Please Log In", false) guiSetVisible(browser, true) showCursor(true) guiSetInputEnabled(true) guiWindowSetMovable(browser, true) guiWindowSetSizable(browser, true) go = guiCreateButton(0.7, 0.1, 0.1, 0.05, "Go!", true) quit = guiCreateButton(0.9, 0.05, 0.03, 0.03, "x", true) end addCommandHandler("internet", Internet) addEventHandler("onClientGUIClick", quit, quitInternet) function quitInternet(button, state) if button == "left" and state == "up" then guiSetInputEnabled(false) guiSetVisible(browser, false) showCursor(false) end end Please, help me. Sorry for my bad English. Edited May 11, 2010 by Guest Link to comment
Castillo Posted May 11, 2010 Share Posted May 11, 2010 You must put the event handler after the funtion, like this function Internet() local screenWidth, screenHeight = guiGetScreenSize() browser = guiCreateWindow(50, 50, screenWidth-100, screenHeight-100, "Please Log In", false) guiSetVisible(browser, true) showCursor(true) guiSetInputEnabled(true) guiWindowSetMovable(browser, true) guiWindowSetSizable(browser, true) go = guiCreateButton(0.7, 0.1, 0.1, 0.05, "Go!", true) quit = guiCreateButton(0.9, 0.05, 0.03, 0.03, "x", true) end addCommandHandler("internet", Internet) function quitInternet(button, state) if button == "left" and state == "up" then guiSetInputEnabled(false) guiSetVisible(browser, false) showCursor(false) end end addEventHandler("onClientGUIClick", quit, quitInternet) oh and remember to use lua tags Link to comment
bmat Posted May 11, 2010 Author Share Posted May 11, 2010 Ok. But this code still doesn't work. Link to comment
Castillo Posted May 11, 2010 Share Posted May 11, 2010 Ok.But this code still doesn't work. local screenWidth, screenHeight = guiGetScreenSize() browser = guiCreateWindow(50, 50, screenWidth-100, screenHeight-100, "Please Log In", false) guiSetVisible(browser,false) guiWindowSetMovable(browser, true) guiWindowSetSizable(browser, true) go = guiCreateButton(0.7, 0.1, 0.1, 0.05, "Go!", true) quit = guiCreateButton(0.9, 0.05, 0.03, 0.03, "x", true) function visible() guiSetVisible(browser, true) showCursor(true) guiSetInputEnabled(true) end addCommandHandler("internet", visible) function quitInternet (button, state) if button == "left" and state == "up" then guiSetInputEnabled(false) guiSetVisible(browser, false) showCursor(false) end end addEventHandler("onClientGUIClick", quit, quitInternet) I edited your code a bit Link to comment
bmat Posted May 11, 2010 Author Share Posted May 11, 2010 It works! Thanks, but when I click a window this one is closing. I want to close window only when I click a button x. Could you help me? Link to comment
Castillo Posted May 11, 2010 Share Posted May 11, 2010 It works!Thanks, but when I click a window this one is closing. I want to close window only when I click a button x. Could you help me? for me works like must work, i dont understand what u mean. Link to comment
dzek (varez) Posted May 11, 2010 Share Posted May 11, 2010 change last line to: addEventHandler("onClientGUIClick", quit, quitInternet,false) 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