GE Lua Documentation

Press F to search!

selectPreviousItem

Definition


-- @/lua/ge/extensions/ui/topBar.lua:51

local selectPreviousItem = function(loop)
  if not M.state.visibleItems or #M.state.visibleItems == 0 then
    return
  end

  local activeIndex = M.state.activeItem and arrayFindValueIndex(M.state.visibleItems, M.state.activeItem) or 1

  if not activeIndex then
    log("W", "", "ui_topBar: selectPreviousItem: activeItem not found in visibleItems: " .. M.state.activeItem)
    return
  end

  if activeIndex > 1 then
    M.selectItem(M.state.visibleItems[activeIndex - 1])
  elseif loop then
    M.selectItem(M.state.visibleItems[#M.state.visibleItems])
  end
end

Callers