NativeUILua icon indicating copy to clipboard operation
NativeUILua copied to clipboard

Auto-select

Open Quadster opened this issue 7 years ago • 6 comments

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.

Quadster avatar Dec 26 '18 21:12 Quadster

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

ImBaphomettt avatar Dec 26 '18 22:12 ImBaphomettt

Thanks, that should do.

Quadster avatar Dec 26 '18 22:12 Quadster

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

Quadster avatar Dec 30 '18 11:12 Quadster

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

Korioz avatar Jan 11 '19 00:01 Korioz

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

ImBaphomettt avatar Jan 22 '19 13:01 ImBaphomettt

Solved ??

ImBaphomettt avatar Jan 27 '19 18:01 ImBaphomettt