Gallagher Posted December 28, 2013 Posted December 28, 2013 I am creating a panel, but did not understand how to detect the click buttons. anyone can do it in this example? for me to learn! tab = {} GUIEditor = { tab = {}, staticimage = {}, label = {}, button = {}, window = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(345, 201, 556, 442, "Will", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.68) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FFD6B104") GUIEditor.button[1] = guiCreateButton(156, 403, 246, 22, "Close", false,GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFC1A801") end )
Dealman Posted December 28, 2013 Posted December 28, 2013 First of all, I'd suggest you get rid of the table containing the GUI Elements which the GUI Editor created for you. And assign each element with a variable. It makes it much easier to work with your code later on. Here's how to make buttons work; mainWindow = guiCreateWindow(345, 201, 556, 442, "Will", false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.68) guiSetProperty(mainWindow, "CaptionColour", "FFD6B104") closeButton = guiCreateButton(156, 403, 246, 22, "Close", false, mainWindow) guiSetProperty(closeButton, "NormalTextColour", "FFC1A801") function exampleCode() if(source == closeButton) then guiSetVisible(mainWindow, false) end end addEventHandler("onClientGUIClick", getRootElement(), exampleCode)
Gallagher Posted December 28, 2013 Author Posted December 28, 2013 First of all, I'd suggest you get rid of the table containing the GUI Elements which the GUI Editor created for you. And assign each element with a variable. It makes it much easier to work with your code later on.Here's how to make buttons work; mainWindow = guiCreateWindow(345, 201, 556, 442, "Will", false) guiWindowSetSizable(mainWindow, false) guiSetAlpha(mainWindow, 0.68) guiSetProperty(mainWindow, "CaptionColour", "FFD6B104") closeButton = guiCreateButton(156, 403, 246, 22, "Close", false, mainWindow) guiSetProperty(closeButton, "NormalTextColour", "FFC1A801") function exampleCode() if(source == closeButton) then guiSetVisible(mainWindow, false) end end addEventHandler("onClientGUIClick", getRootElement(), exampleCode) thanks
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