Jump to content

GUI Button handling


SjoerdPSV

Recommended Posts

Posted

Hello

I was scripting a GUI and for the button handling I made this function:

function buttonHandling() 
    outputDebugString("test1") 
    local input = guiGetText(GUIEditor.edit[1]) 
    if (source == GUIEditor.button[1]) then 
        guiSetText(GUIEditor.edit[1], input.."1") 
        outputDebugString("test2") 
    elseif (source == GUIeditor.button[9]) then     
        guiSetText(GUIEditor.edit[1], input.."2") 
    elseif (source == GUIeditor.button[8]) then     
        guiSetText(GUIEditor.edit[1], input.."3") 
    elseif (source == GUIeditor.button[8]) then     
        guiSetText(GUIEditor.edit[1], input.."4") 
    elseif (source == GUIeditor.button[7]) then     
        guiSetText(GUIEditor.edit[1], input.."5")  
    elseif (source == GUIeditor.button[6]) then     
        guiSetText(GUIEditor.edit[1], input.."6") 
    elseif (source == GUIeditor.button[5]) then     
        guiSetText(GUIEditor.edit[1], input.."7") 
    elseif (source == GUIeditor.button[4]) then     
        guiSetText(GUIEditor.edit[1], input.."8") 
    elseif (source == GUIeditor.button[3]) then     
        guiSetText(GUIEditor.edit[1], input.."9") 
    elseif (source == GUIeditor.button[2]) then     
        guiSetText(GUIEditor.edit[1], input.."0")     
    end 
end     
addEventHandler("OnClientGUIClick", root, buttonHandling) 

But it doesn't work, the outputDebugString are not popping up in my /debugscript. I can't find out what's wrong with this and I'm 100% sure that all GUIelements are the right ones (the ones after source ==)

Is it becuase I set it on read only? Or shouldn't that be a problem?

Posted

Show me your GUI.

also here :

addEventHandler("OnClientGUIClick", root, buttonHandling) 

it should be like this:

addEventHandler("onClientGUIClick", root, buttonHandling) 

Failure is simply an opportunity to begin again more intelligently - Henry Ford

Posted

Me4ever has the solution, event names are case sensitive and starts with a lowercase char always, at least default events does that. Don't worry, this is a common error, except for that it looks well. Debug script won't output anything because the event is never triggered, it's nothing wrong in it tho.

function be_remove() {

        printf("Too much gaming and too little sleep makes Olle wanna kill...");

        be_remove();

}

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