Jump to content

Problem with buttons in a tab


Chlorek

Recommended Posts

Hi there. I am scripting some GUI and I found some problems with buttons in tabs. First of all I have to use relative=true when creating button (when I don't I do not see button). However when I used it I found another one problem - whereever I click in the tab the button is activated, but should only if button is clicked - really weird problem. Thanks for help!

Link to comment
  
local tabs = guiCreateTabPanel(5, 20, width-10, height-25, false, mainWindow) 
local tabLogin = guiCreateTab("Login", tabs) 
local tabRegister = guiCreateTab("Register", tabs) 
local nameStatic = guiCreateLabel((width-60)/2, 5, 60, 20, "Username:", false, tabLogin) 
local nameEdit = guiCreateEdit((width-200)/2, 25, 200, 25, "", false, tabLogin) guiEditSetMaxLength(nameEdit, 25) --guiSetProperty(nameEdit, "TextFormatting", "HorzCentred") 
local passwdStatic = guiCreateLabel((width-60)/2, 65, 60, 20, "Password:", false, tabLogin) 
local passwdEdit = guiCreateEdit((width-200)/2, 83, 200, 25, "", false, tabLogin) guiSetProperty(passwdEdit, "MaskText", "True") guiEditSetMaxLength(passwdEdit, 30) 
local loginbtn = guiCreateButton(0.1, 0.8, 0.8, 0.1, "Log Me In", true, tabLogin) 
  

This is my code, loginbtn is invisible when I set relative to false and use pixels. It happens only when I create button in a tab. And in relative mode my button is clicked when I click wherever in Login tab.

My button click event handler (OH, it's register button handler, but they are the same so no matter):

  
unction sendRegisterRequest(button, state) 
    if button == "left" and state == "up" then 
        triggerServerEvent("sendRegisterRequest", getLocalPlayer(), guiGetText(nameEditReg), guiGetText(passwdEditReg), guiGetText(rpasswdEditReg)) 
    end 
end 
addEventHandler("onClientGUIClick", registerbtn, sendRegisterRequest) 
  

Link to comment

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...