ah great to see this topic i got the same/a similar problem and was just about starting a new topic for it^^
First i started to look for something like this in the standart resource and found out that in the stealthmain_client.lua file the eventhandler for onClientGUIClick is placed in the same function where the button is created so i tried the same in my code...
I used this:
vehicles = {
"rc_baron",
"rc_tiger",
"rc_goblin"
}
function spawn (button, state, absoluteX, absoluteY)
outputChatBox ("Clicked")
end
function guiMenu ()
showCursor ( true )
Menu = guiCreateWindow ( 0.15, 0.33, 0.7, 0.34, "Select your vehicle", true )
OKButton = guiCreateButton ( 0.4, 0.85, 0.20, 0.15, "OK", true, Menu )
guiWindowSetMovable ( Menu, false )
guiWindowSetSizable ( Menu, false )
GridList = guiCreateGridList ( 0, 0.1, 1, 0.9, true, Menu )
guiGridListSetSelectionMode ( GridList, 2 )
guiGridListAddColumn ( GridList, "Vehicles", 0.3 )
for key,vehicleName in pairs(vehicles) do
local row = guiGridListAddRow ( GridList )
guiGridListSetItemText ( GridList, row, 1, vehicleName, false, false )
end
addEventHandler ("onClientGUIClick", OKButton, spawn)
end
But what happened now was really strange. The Button went really dark as if it is placed behind the window and if i clicked on it nothing happened. But if i clicked on the border of the window somehow the function spawn was called... As if the declaration OKButton in the eventhandler also declares the parent elements of the button, the Window.
I hope someone can help xeta and me with this problem =)