Author Topic: Perform an action upon selecting a GUI text list row?  (Read 970 times)

How do I script GUI so that selecting a row sends a command?

<nvm the code was for double clicking>
« Last Edit: June 01, 2017, 11:05:44 PM by Kyuande »

Give your GuiTextListCtrl a name. You'll then be able to create a function named onSelect for the object and it'll be called when an item is selected.

function MyList::onSelect(%this, %rowID, %rowText)

I haven't been able to make this list do anything.  Please check over my code and tell me what's wrong.

https://pastebin.com/mbsfGKLK

Are you sure you're testing the right thing? You filled boardsList with dummy values, but only implemented the callback for addonsList. So if you click something in boardsList nothing will happen.

You also need to use less generic object and function names. All add-ons are loaded into the global namespace, so the only way to protect yourself from accidently using the same name as another add-on (and breaking the whole game in the process) is to prefix all your names with something related to your add-on.

Are you sure you're testing the right thing? You filled boardsList with dummy values, but only implemented the callback for addonsList. So if you click something in boardsList nothing will happen.

You also need to use less generic object and function names. All add-ons are loaded into the global namespace, so the only way to protect yourself from accidently using the same name as another add-on (and breaking the whole game in the process) is to prefix all your names with something related to your add-on.

You're right! I called the wrong list item.

And thank you for the latter suggestion.