Jump to content

New problem with GUI


Piorun

Recommended Posts

Posted

I've got a problem. Here's a code:

function build_Form( commandName, typ )
 
if (typ == "stworz") then
 
showCursor ( true, true )
 
local gui = {}
gui._placeHolders = {}
 
local screenWidth, screenHeight = guiGetScreenSize()
local windowWidth, windowHeight = 451, 238
local left = screenWidth/2 - windowWidth/2
local top = screenHeight/2 - windowHeight/2
gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "Tworzenie nowego biznesu cz. 1", false)
guiWindowSetSizable(gui["_root"], false)
 
gui["pushButton"] = guiCreateButton(80, 205, 75, 23, "Ok", false, gui["_root"])
 
gui["pushButton_2"] = guiCreateButton(290, 205, 75, 23, "Anuluj", false, gui["_root"])
 
gui["lineEdit"] = guiCreateEdit(10, 45, 431, 20, "", false, gui["_root"])
guiEditSetMaxLength(gui["lineEdit"], 32767)
 
gui["label"] = guiCreateLabel(20, 25, 46, 13, "Nazwa", false, gui["_root"])
guiLabelSetHorizontalAlign(gui["label"], "left", false)
guiLabelSetVerticalAlign(gui["label"], "center")
 
gui["radioButton"] = guiCreateRadioButton(40, 105, 41, 17, "Bar", false, gui["_root"])
 
gui["radioButton_2"] = guiCreateRadioButton(40, 125, 51, 17, "Hotel", false, gui["_root"])
 
gui["radioButton_3"] = guiCreateRadioButton(40, 145, 51, 17, "Sklep", false, gui["_root"])
 
gui["label_2"] = guiCreateLabel(20, 85, 46, 13, "Typ", false, gui["_root"])
guiLabelSetHorizontalAlign(gui["label_2"], "left", false)
guiLabelSetVerticalAlign(gui["label_2"], "center")
 
gui["radioButton_4"] = guiCreateRadioButton(130, 105, 82, 17, "Bank", false, gui["_root"])
 
gui["radioButton_5"] = guiCreateRadioButton(130, 125, 82, 17, "Komisariat", false, gui["_root"])
 
gui["radioButton_6"] = guiCreateRadioButton(130, 145, 82, 17, "Klub", false, gui["_root"])
 
addEventHandler ( "onClientGUIClick", gui["pushButton_2"], guiAnulujClick, false)
 
return gui, windowWidth, windowHeight
 
end
 
end
addCommandHandler ( "biznes", build_Form )
 
function guiAnulujClick ( )
guiSetVisible ( gui["_root"], false )
showCursor (false)		
end

And when I'm clicking a gui["pushButton_2"] window is still visible.

Please, help :D

Posted

that happends bcoz your "gui" variable is set locally in your build_form function and so the other function, guiAnulujClick doesnt know about it, you have to declare it at the top of the script, outside of any functions

Posted

move "local gui = {}" above "function build_Form( commandName, typ )" like this:

local gui = {}
function build_Form(  commandName, typ )
 
if (typ == "stworz") then
 
showCursor ( true, true )
 
  gui._placeHolders = {}
 
local screenWidth, screenHeight = guiGetScreenSize()
local windowWidth, windowHeight = 451, 238
local left = screenWidth/2 - windowWidth/2
local top = screenHeight/2 - windowHeight/2
  gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "Tworzenie nowego biznesu cz. 1", false)
guiWindowSetSizable(gui["_root"], false)
 
  gui["pushButton"] = guiCreateButton(80, 205, 75, 23, "Ok", false, gui["_root"])
 
  gui["pushButton_2"] = guiCreateButton(290, 205, 75, 23, "Anuluj", false, gui["_root"])
 
  gui["lineEdit"] = guiCreateEdit(10, 45, 431, 20, "", false, gui["_root"])
guiEditSetMaxLength(gui["lineEdit"], 32767)
 
  gui["label"] = guiCreateLabel(20, 25, 46, 13, "Nazwa", false, gui["_root"])
guiLabelSetHorizontalAlign(gui["label"], "left", false)
guiLabelSetVerticalAlign(gui["label"], "center")
 
  gui["radioButton"] = guiCreateRadioButton(40, 105, 41, 17, "Bar", false, gui["_root"])
 
  gui["radioButton_2"] = guiCreateRadioButton(40, 125, 51, 17, "Hotel", false, gui["_root"])
 
  gui["radioButton_3"] = guiCreateRadioButton(40, 145, 51, 17, "Sklep", false, gui["_root"])
 
  gui["label_2"] = guiCreateLabel(20, 85, 46, 13, "Typ", false, gui["_root"])
guiLabelSetHorizontalAlign(gui["label_2"], "left", false)
guiLabelSetVerticalAlign(gui["label_2"], "center")
 
  gui["radioButton_4"] = guiCreateRadioButton(130, 105, 82, 17, "Bank", false, gui["_root"])
 
  gui["radioButton_5"] = guiCreateRadioButton(130, 125, 82, 17, "Komisariat", false, gui["_root"])
 
  gui["radioButton_6"] = guiCreateRadioButton(130, 145, 82, 17, "Klub", false, gui["_root"])
 
addEventHandler ( "onClientGUIClick", gui["pushButton_2"], guiAnulujClick, false)
 
return gui, windowWidth, windowHeight
 
end
 
end
addCommandHandler ( "biznes", build_Form )
 
function guiAnulujClick ( )
guiSetVisible ( gui["_root"], false )
showCursor (false)      
end

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...