menuTab
A tab is a <name>.menuTab/ folder whose init.luau returns its spec:
return {
title = "Game",
build = function(ctx)
-- ctx.presentation: "desktop" | "phone" | "vr"; ctx.width, ctx.height:
-- the room the body has inside the menu's frame.
return { type = "vertical", children = { ... } }
end,
onCallback = function(id, data) end, -- every callback the body raises
back = function() return false end, -- one step back inside the tab
frameless = function() return false end, -- stand in the whole window, no frame
onShow = function(ctx) end, -- each time the tab comes on screen
}
title is text, or { key = "namespace.key", values? } for the catalog
message the menu says in the player's language each time it draws. A new
world's tab reads the library's app_menu messages that way.
A tab whose body shows state of its own (a settings value, a counter, the
page of a sub-menu it is on) changes that state and calls appMenu.redraw():
the menu calls build again and draws what it returns. It works from
onCallback and from anywhere else the state changes, a task or a timer
included:
local volume = 5
return {
title = "Game",
build = function(ctx)
return { type = "vertical", children = {
{ type = "label", props = { text = `Volume {volume}` } },
{ type = "button", props = { text = "+", onClick = "game:louder" } },
} }
end,
onCallback = function(id)
if id == "game:louder" then
volume += 1
appMenu.redraw()
end
end,
}
The menu builds the tab it shows afresh each time it opens and each time a tab is selected, so a change made while the menu is closed shows when it opens.
The body is an ordinary widget tree, the one ui.registerScreen takes, so a
tab looks the way its world draws it. The menu draws the frame around it:
Resume (back to the world), Enter or Exit VR, Recenter in a headset, and the
tabs, across the top on a desktop, along the bottom on a phone, and along
the bottom edge of the panel in a headset.
A tab whose frameless() answers true stands in the whole window with no
frame around it, on a desktop and a phone (a headset keeps the frame): no
brand, no tabs, no Resume. The ZeroMind tab does that below a host's own
navigation while no world runs, so a page that boots the engine onto it
shows the tab's content directly under the page's top bar.
Which tabs the menu counts is decided by where the asset lives:
- The world's own source (
/source, outsidelibs/anddeps/): the world's tab, shown first as the World tab whatever the folder is named. A new world starts with one,menuTabs/game.menuTab, which the world rewrites for its game. A world with none shows its title, Resume and the way to another world. - The built-in library: the engine's tabs, ZeroMind
(
@builtin::menuTabs.zeromind) and System (@builtin::menuTabs.system). - Anywhere else, another library or the dependency tree of a world installed into this one: nothing. An installed world brings its content and no menu of its own.
Opening the menu pauses nothing: every world is shared, and keeps running. Menu tabs stay out of search.