Jump to content

OnClientGUIClick triggering when clicking on window and not button


harryh

Recommended Posts

function loadGUI()

Adder.Window = guiCreateWindow(lx*500, ly*500, 404, 250, "Object Adder", false)

Adder.Button = guiCreateButton(0.62, 0.26, 0.33, 0.66, "ADD OBJECT", true, Adder.Window)

addEventHandler( "onClientGUIClick", Adder.Button, sendData)
end
addEventHandler( "onClientResourceStart", getRootElement(  ), loadGUI )

If I click on the gui window Adder.Window it executes sendData() when it should on execute if click on button

 

 

Link to comment
  • Discord Moderators

Set fourth argument in addEventHandler to false. Like this:

addEventHandler( "onClientGUIClick", Adder.Button, sendData, false)

By default the event propagates up and down, so when you click on a button it also triggers the event handler for the window, as the window is the parent of the button.

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