mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
refactor: Add h1 headers to all pages missing it (#137)
* refactor: Add h1 headers to all pages missing it * refactor: missed example h3 * change hooks example heading to bold text --------- Co-authored-by: Luke <[email protected]>
This commit is contained in:
1 parent
74227cc262
commit
1d2c490b26
95 files changed
+2167
-2289
No files matched your search
@@ -5,29 +5,27 @@ title: Menu
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
# Menu
|
||||
|
||||
Keyboard navigation menu with specific event functions.
|
||||
|
||||
### lib.registerMenu
|
||||
## lib.registerMenu
|
||||
|
||||
Registers and caches a menu under the specified id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(data, cb);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.registerMenu(data, cb);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- data: `table` (`object`)
|
||||
@@ -74,97 +72,81 @@ lib.registerMenu(data, cb);
|
||||
- cb: `function`(selected: `number`, scrollIndex: `number`, args: `{[string]: any}`)
|
||||
- Callback function when the menu item is pressed.
|
||||
|
||||
### lib.showMenu
|
||||
## lib.showMenu
|
||||
|
||||
Displays the menu with the provided id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.showMenu(id)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.showMenu(id)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showMenu(id);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.showMenu(id);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.hideMenu
|
||||
## lib.hideMenu
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideMenu(onExit);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.hideMenu(onExit);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- onExit?: `boolean`
|
||||
- If true runs the menu's `onClose` function.
|
||||
|
||||
### lib.getOpenMenu
|
||||
## lib.getOpenMenu
|
||||
|
||||
Returns the id of the currently open menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.getOpenMenu();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.getOpenMenu();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.setMenuOptions
|
||||
## lib.setMenuOptions
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setMenuOptions(id, options, index);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.setMenuOptions(id, options, index);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
@@ -172,30 +154,26 @@ lib.setMenuOptions(id, options, index);
|
||||
- index?: `number`
|
||||
- If specified only sets the options table on the specified options index.
|
||||
|
||||
**Example:**
|
||||
### Example
|
||||
|
||||
Replaces the 3rd index option of the specified menu
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setMenuOptions('some_menu_id', { label: 'New option', icon: 'plus' }, 3);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.setMenuOptions('some_menu_id', { label: 'New option', icon: 'plus' }, 3);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
## Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
@@ -204,127 +182,123 @@ First we register the menu with our specified options then we call the show func
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.registerMenu({
|
||||
id = 'some_menu_id',
|
||||
title = 'Menu title',
|
||||
position = 'top-right',
|
||||
onSideScroll = function(selected, scrollIndex, args)
|
||||
print("Scroll: ", selected, scrollIndex, args)
|
||||
end,
|
||||
onSelected = function(selected, secondary, args)
|
||||
if not secondary then
|
||||
print("Normal button")
|
||||
else
|
||||
if args.isCheck then
|
||||
print("Check button")
|
||||
end
|
||||
|
||||
```lua
|
||||
lib.registerMenu({
|
||||
id = 'some_menu_id',
|
||||
title = 'Menu title',
|
||||
position = 'top-right',
|
||||
onSideScroll = function(selected, scrollIndex, args)
|
||||
print("Scroll: ", selected, scrollIndex, args)
|
||||
end,
|
||||
onSelected = function(selected, secondary, args)
|
||||
if not secondary then
|
||||
print("Normal button")
|
||||
else
|
||||
if args.isCheck then
|
||||
print("Check button")
|
||||
if args.isScroll then
|
||||
print("Scroll button")
|
||||
end
|
||||
end
|
||||
|
||||
if args.isScroll then
|
||||
print("Scroll button")
|
||||
print(selected, secondary, json.encode(args, {indent=true}))
|
||||
end,
|
||||
onCheck = function(selected, checked, args)
|
||||
print("Check: ", selected, checked, args)
|
||||
end,
|
||||
onClose = function(keyPressed)
|
||||
print('Menu closed')
|
||||
if keyPressed then
|
||||
print(('Pressed %s to close the menu'):format(keyPressed))
|
||||
end
|
||||
end
|
||||
print(selected, secondary, json.encode(args, {indent=true}))
|
||||
end,
|
||||
onCheck = function(selected, checked, args)
|
||||
print("Check: ", selected, checked, args)
|
||||
end,
|
||||
onClose = function(keyPressed)
|
||||
print('Menu closed')
|
||||
if keyPressed then
|
||||
print(('Pressed %s to close the menu'):format(keyPressed))
|
||||
end
|
||||
end,
|
||||
options = {
|
||||
{label = 'Simple button', description = 'It has a description!'},
|
||||
{label = 'Checkbox button', checked = true},
|
||||
{label = 'Scroll button with icon', icon = 'arrows-up-down-left-right', values={'hello', 'there'}},
|
||||
{label = 'Button with args', args = {someArg = 'nice_button'}},
|
||||
{label = 'List button', values = {'You', 'can', 'side', 'scroll', 'this'}, description = 'It also has a description!'},
|
||||
{label = 'List button with default index', values = {'You', 'can', 'side', 'scroll', 'this'}, defaultIndex = 5},
|
||||
{label = 'List button with args', values = {'You', 'can', 'side', 'scroll', 'this'}, args = {someValue = 3, otherValue = 'value'}},
|
||||
}
|
||||
}, function(selected, scrollIndex, args)
|
||||
print(selected, scrollIndex, args)
|
||||
end)
|
||||
|
||||
RegisterCommand('testmenu', function()
|
||||
lib.showMenu('some_menu_id')
|
||||
end)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(
|
||||
{
|
||||
id: 'some_menu_id',
|
||||
title: 'Menu title',
|
||||
position: 'top-right',
|
||||
onSideScroll: (selected, scrollIndex, args) => {
|
||||
console.log('Scroll: ', selected, scrollIndex, args);
|
||||
},
|
||||
onSelected: (selected, secondary, args) => {
|
||||
if (!secondary) {
|
||||
console.log('Normal button');
|
||||
} else {
|
||||
if (args.isCheck) {
|
||||
console.log('Check button');
|
||||
end,
|
||||
options = {
|
||||
{label = 'Simple button', description = 'It has a description!'},
|
||||
{label = 'Checkbox button', checked = true},
|
||||
{label = 'Scroll button with icon', icon = 'arrows-up-down-left-right', values={'hello', 'there'}},
|
||||
{label = 'Button with args', args = {someArg = 'nice_button'}},
|
||||
{label = 'List button', values = {'You', 'can', 'side', 'scroll', 'this'}, description = 'It also has a description!'},
|
||||
{label = 'List button with default index', values = {'You', 'can', 'side', 'scroll', 'this'}, defaultIndex = 5},
|
||||
{label = 'List button with args', values = {'You', 'can', 'side', 'scroll', 'this'}, args = {someValue = 3, otherValue = 'value'}},
|
||||
}
|
||||
}, function(selected, scrollIndex, args)
|
||||
print(selected, scrollIndex, args)
|
||||
end)
|
||||
|
||||
if (args.isScroll) {
|
||||
console.log('Scroll button');
|
||||
}
|
||||
}
|
||||
console.log(selected, secondary, JSON.stringify(args, null, 2));
|
||||
},
|
||||
onCheck: (selected, checked, args) => {
|
||||
console.log('Check: ', selected, checked, args);
|
||||
},
|
||||
onClose: (keyPressed) => {
|
||||
console.log('Menu closed');
|
||||
if (keyPressed) {
|
||||
console.log(`Pressed ${keyPressed} to close the menu`);
|
||||
}
|
||||
},
|
||||
options: [
|
||||
{ label: 'Simple button', description: 'It has a description!' },
|
||||
{ label: 'Checkbox button', checked: true },
|
||||
{ label: 'Scroll button with icon', icon: 'arrows-up-down-left-right', values: ['hello', 'there'] },
|
||||
{ label: 'Button with args', args: { someArg: 'nice_button' } },
|
||||
RegisterCommand('testmenu', function()
|
||||
lib.showMenu('some_menu_id')
|
||||
end)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(
|
||||
{
|
||||
label: 'List button',
|
||||
values: ['You', 'can', 'side', 'scroll', 'this'],
|
||||
description: 'It also has a description!',
|
||||
},
|
||||
{ label: 'List button with default index', values: ['You', 'can', 'side', 'scroll', 'this'], defaultIndex: 5 },
|
||||
{
|
||||
label: 'List button with args',
|
||||
values: ['You', 'can', 'side', 'scroll', 'this'],
|
||||
args: { someValue: 3, otherValue: 'value' },
|
||||
},
|
||||
],
|
||||
},
|
||||
(selected, scrollIndex, args) => {
|
||||
console.log(selected, scrollIndex, args);
|
||||
}
|
||||
);
|
||||
id: 'some_menu_id',
|
||||
title: 'Menu title',
|
||||
position: 'top-right',
|
||||
onSideScroll: (selected, scrollIndex, args) => {
|
||||
console.log('Scroll: ', selected, scrollIndex, args);
|
||||
},
|
||||
onSelected: (selected, secondary, args) => {
|
||||
if (!secondary) {
|
||||
console.log('Normal button');
|
||||
} else {
|
||||
if (args.isCheck) {
|
||||
console.log('Check button');
|
||||
}
|
||||
|
||||
RegisterCommand(
|
||||
'testmenu',
|
||||
() => {
|
||||
lib.showMenu('some_menu_id');
|
||||
},
|
||||
false
|
||||
);
|
||||
```
|
||||
if (args.isScroll) {
|
||||
console.log('Scroll button');
|
||||
}
|
||||
}
|
||||
console.log(selected, secondary, JSON.stringify(args, null, 2));
|
||||
},
|
||||
onCheck: (selected, checked, args) => {
|
||||
console.log('Check: ', selected, checked, args);
|
||||
},
|
||||
onClose: (keyPressed) => {
|
||||
console.log('Menu closed');
|
||||
if (keyPressed) {
|
||||
console.log(`Pressed ${keyPressed} to close the menu`);
|
||||
}
|
||||
},
|
||||
options: [
|
||||
{ label: 'Simple button', description: 'It has a description!' },
|
||||
{ label: 'Checkbox button', checked: true },
|
||||
{ label: 'Scroll button with icon', icon: 'arrows-up-down-left-right', values: ['hello', 'there'] },
|
||||
{ label: 'Button with args', args: { someArg: 'nice_button' } },
|
||||
{
|
||||
label: 'List button',
|
||||
values: ['You', 'can', 'side', 'scroll', 'this'],
|
||||
description: 'It also has a description!',
|
||||
},
|
||||
{ label: 'List button with default index', values: ['You', 'can', 'side', 'scroll', 'this'], defaultIndex: 5 },
|
||||
{
|
||||
label: 'List button with args',
|
||||
values: ['You', 'can', 'side', 'scroll', 'this'],
|
||||
args: { someValue: 3, otherValue: 'value' },
|
||||
},
|
||||
],
|
||||
},
|
||||
(selected, scrollIndex, args) => {
|
||||
console.log(selected, scrollIndex, args);
|
||||
}
|
||||
);
|
||||
|
||||
</Tab>
|
||||
RegisterCommand(
|
||||
'testmenu',
|
||||
() => {
|
||||
lib.showMenu('some_menu_id');
|
||||
},
|
||||
false
|
||||
);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
Reference in new issue
Block a user