Auto-select
Is there a way to not auto-instant-select the item when changing an menu.OnListChange?
Like make you able to first scroll through the options and then hit enter to select one?
Im sorry for opening an issue for this.
Yes. https://github.com/FrazzIe/NativeUILua/blob/master/NativeUI/items/UIMenuListItem.lua#L17 https://github.com/FrazzIe/NativeUILua/blob/master/NativeUI/items/UIMenuSliderItem.lua#L19 https://github.com/FrazzIe/NativeUILua/blob/master/NativeUI/items/UIMenuProgressItem.lua#L19
if you issue is solved, you can close this. 👍
Thanks, that should do.
Alright.. when having 2 of those in one menu only 1 will work.. or am I doing something wrong here?
function AddMenuDrinks(menu)
local drink = {
"Coca-Cola",
"Ice-Tea",
"Sprite",
}
local newitem = NativeUI.CreateListItem("Drinks", drink, 1)
menu:AddItem(newitem)
menu.OnListSelect = function(sender, item, index)
if item == newitem then
drank = item:IndexToItem(index)
ShowNotification("~b~You bought: ~s~" .. drank .. "~w~")
end
end
end
function AddMenuFoods(menu)
local food = {
"Hamburger",
"Chicken Nuggets",
"Bread",
}
local newitem = NativeUI.CreateListItem("Foods", food, 1)
menu:AddItem(newitem)
menu.OnListSelect = function(sender, item, index)
if item == newitem then
dish = item:IndexToItem(index)
ShowNotification("You bought ~b~" .. dish .. "~w~")
end
end
end
Yeah you are doing something wrong, you have two times the same variables "dish" change the name of the second one or add "local" in front of the var
local food = {
"Hamburger",
"Chicken Nuggets",
"Bread",
}
local drink = {
"Coca-Cola",
"Ice-Tea",
"Sprite",
}
local foodItem = NativeUI.CreateListItem("Food", food, 1)
local drinkItem = NativeUI.CreateListItem("Drink", drink, 1)
menu:AddItem(foodItem)
menu:AddItem(drinkItem)
menu.OnListChange = function(sender, item, index)
if item == foodItem then
dish = item:IndexToItem(index)
ShowNotification("foodItem ~b~" .. dish .. "~w~...")
elseif item == drinkItem then
dish = item:IndexToItem(index)
ShowNotification("drinkItem ~b~" .. dish .. "~w~...")
end
end
Sorry for the late response...
if you issue is solved, you can close this. 👍
Solved ??