Jump to content

GUI


Mefisto_PL

Recommended Posts

This is a simple example:

--We create a table with two items on it. 
local dataTable = { 
    ["Dog"] = "Ugly", 
    ["Cat"] = "Nice", 
} 
  
myGridList = guiCreateGridList(382, 221, 200, 201, false) --We create our GUI gridlist. 
guiGridListAddColumn(myGridList,"",0.70) --We add a column to our gridlist. 
for question, answer in pairs(dataTable) do --We loop through our "dataTable". 
    local row = guiGridListAddRow(myGridList) --We add a row to our gridlist. 
    guiGridListSetItemText(myGridList,row,1,tostring(question),false,false) --We set the column text to the data obtained from the table. 
    guiGridListSetItemData(myGridList,row,1,tostring(answer)) --We the column data as the "answer". 
end 
myMemo = guiCreateMemo(591,221,175,53,"",false) --We create our GUI memo. 
  
addEventHandler("onClientGUIClick",myGridList, 
function () 
    local row,col = guiGridListGetSelectedItem(source) --We get the gridlist selected item.. 
    if (row and col and row ~= -1 and col ~= -1) then --We check if the row and column is valid.. 
        local answer = guiGridListGetItemData(source, row, 1) --We get the selected item data (the answer).. 
        guiSetText(myMemo, answer) --We set the our memo text with the text obtained above. 
    else --If row and column aren't valid... 
        guiSetText(myMemo, "") --We our memo text to nothing. 
    end 
end, false) 

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