Skip to content
This repository has been archived by the owner on Mar 2, 2019. It is now read-only.

Auto-select #23

Open
Quadster opened this issue Dec 26, 2018 · 6 comments
Open

Auto-select #23

Quadster opened this issue Dec 26, 2018 · 6 comments

Comments

@Quadster
Copy link

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
Copy link
Author

Thanks, that should do.

@Quadster
Copy link
Author

Quadster commented Dec 30, 2018

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 Quadster reopened this Dec 30, 2018
@Korioz
Copy link

Korioz commented Jan 11, 2019

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

@ImBaphomettt
Copy link

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
Copy link

Solved ??

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants