mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 06:28:54 +00:00
Update context menu info and list menu image
This commit is contained in:
1 parent
2d3347d5d2
commit
bd4e1368c5
2 files changed
+83
-74
No files matched your search
@@ -90,100 +90,106 @@ lib.getOpenContextMenu()
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Usage Example
|
### Usage Example
|
||||||
This is a simple command that will register and open a
|
First we register the menu with our specified options then we call the show function in the command.
|
||||||
context menu.
|
|
||||||
|
:::tip
|
||||||
|
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
||||||
|
:::
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='custom' label='Custom order'>
|
<TabItem value='custom' label='Custom order'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
RegisterCommand('testcontext', function()
|
lib.registerContext({
|
||||||
lib.registerContext({
|
id = 'example_menu',
|
||||||
id = 'example_menu',
|
title = 'Example Context',
|
||||||
title = 'Example Context',
|
onExit = function()
|
||||||
onExit = function()
|
print('Hello there')
|
||||||
print('Hello there')
|
end,
|
||||||
end,
|
options = {
|
||||||
options = {
|
{title = 'Empty button'},
|
||||||
{title = 'Empty button'},
|
{
|
||||||
{
|
title = 'Example button',
|
||||||
title = 'Example button',
|
description = 'Example button description',
|
||||||
description = 'Example button description',
|
metadata = {
|
||||||
metadata = {
|
{label = 'Value 1', value = 'Some value'},
|
||||||
{label = 'Value 1', value = 'Some value'},
|
{label = 'Value 2', value = 300},
|
||||||
{label = 'Value 2', value = 300},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title = 'Menu button',
|
|
||||||
menu = 'other_example_menu',
|
|
||||||
description = 'Takes you to another menu!',
|
|
||||||
metadata = {'It also has metadata support'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title = 'Event button',
|
|
||||||
description = 'Open a menu and send event data',
|
|
||||||
arrow = true,
|
|
||||||
event = 'some_event',
|
|
||||||
args = {value1 = 300, value2 = 'Other value'}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = 'other_example_menu',
|
title = 'Menu button',
|
||||||
title = 'Other Context Menu',
|
menu = 'other_example_menu',
|
||||||
menu = 'example_menu',
|
description = 'Takes you to another menu!',
|
||||||
options = {
|
metadata = {'It also has metadata support'}
|
||||||
['Nothing here'] = {}
|
},
|
||||||
}
|
{
|
||||||
|
title = 'Event button',
|
||||||
|
description = 'Open a menu and send event data',
|
||||||
|
arrow = true,
|
||||||
|
event = 'some_event',
|
||||||
|
args = {value1 = 300, value2 = 'Other value'}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
lib.showContext('example_menu')
|
{
|
||||||
end)
|
id = 'other_example_menu',
|
||||||
|
title = 'Other Context Menu',
|
||||||
|
menu = 'example_menu',
|
||||||
|
options = {
|
||||||
|
['Nothing here'] = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='ordered' label='Alphabetically ordered'>
|
<TabItem value='ordered' label='Alphabetically ordered'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
RegisterCommand('testcontext', function()
|
lib.registerContext({
|
||||||
lib.registerContext({
|
id = 'example_menu',
|
||||||
id = 'example_menu',
|
title = 'Example Context',
|
||||||
title = 'Example Context',
|
onExit = function()
|
||||||
options = {
|
print('Hello there')
|
||||||
['Empty button'] = {},
|
end,
|
||||||
['Example button'] = {
|
options = {
|
||||||
description = 'Example button description',
|
['Empty button'] = {},
|
||||||
metadata = {
|
['Example button'] = {
|
||||||
['Value 1'] = 'Some value',
|
description = 'Example button description',
|
||||||
['Value 2'] = 300
|
metadata = {
|
||||||
}
|
['Value 1'] = 'Some value',
|
||||||
},
|
['Value 2'] = 300
|
||||||
['Menu button'] = {
|
|
||||||
menu = 'other_example_menu',
|
|
||||||
description = 'Takes you to another menu',
|
|
||||||
metadata = {'It also has metadata support'}
|
|
||||||
},
|
|
||||||
['Event button'] = {
|
|
||||||
description = 'Open a menu and send event data',
|
|
||||||
arrow = true,
|
|
||||||
event = 'some_event',
|
|
||||||
args = {value1 = 300, value2 = 'Other value'}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
['Menu button'] = {
|
||||||
id = 'other_example_menu',
|
menu = 'other_example_menu',
|
||||||
title = 'Other Context Menu',
|
description = 'Takes you to another menu',
|
||||||
menu = 'example_menu',
|
metadata = {'It also has metadata support'}
|
||||||
options = {
|
},
|
||||||
['Nothing here'] = {}
|
['Event button'] = {
|
||||||
}
|
description = 'Open a menu and send event data',
|
||||||
|
arrow = true,
|
||||||
|
event = 'some_event',
|
||||||
|
args = {value1 = 300, value2 = 'Other value'}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
lib.showContext('example_menu')
|
{
|
||||||
end)
|
id = 'other_example_menu',
|
||||||
|
title = 'Other Context Menu',
|
||||||
|
menu = 'example_menu',
|
||||||
|
options = {
|
||||||
|
['Nothing here'] = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
RegisterCommand('testcontext', function()
|
||||||
|
lib.showContext('example_menu')
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
To trigger the event from the `Event button` and get it's data we first
|
To trigger the event from the `Event button` and get it's data we first
|
||||||
need to register the event properly:
|
need to register the event properly:
|
||||||
|
|
||||||
@@ -224,4 +230,4 @@ with the `lib.showContext` function, passing in the menu's id.
|
|||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
@@ -17,6 +17,7 @@ Registers and caches a menu under the specified id.
|
|||||||
-- values: table of strings (optional - if provided creates a side scrollable list)
|
-- values: table of strings (optional - if provided creates a side scrollable list)
|
||||||
-- defaultIndex: number (optional - sets the current index for the list to specified number)
|
-- defaultIndex: number (optional - sets the current index for the list to specified number)
|
||||||
-- args: any (optional)
|
-- args: any (optional)
|
||||||
|
-- position: 'top-left' or 'top-right' or 'bottom-left' or 'bottom-right' (optional - default is top-left)
|
||||||
-- onClose: function (optional)
|
-- onClose: function (optional)
|
||||||
-- onSelected: function (optional - triggers every time a new button is selected)
|
-- onSelected: function (optional - triggers every time a new button is selected)
|
||||||
-- onSideScroll: function (optional - triggers every time a side list is scrolled)
|
-- onSideScroll: function (optional - triggers every time a side list is scrolled)
|
||||||
@@ -78,6 +79,7 @@ Avoid constantly re-registering a menu that does not depend on any outside value
|
|||||||
lib.registerMenu({
|
lib.registerMenu({
|
||||||
id = 'some_menu_id',
|
id = 'some_menu_id',
|
||||||
title = 'Menu title',
|
title = 'Menu title',
|
||||||
|
position = 'top-right',
|
||||||
onSideScroll = function(selected, scrollIndex, args)
|
onSideScroll = function(selected, scrollIndex, args)
|
||||||
print(selected, scrollIndex, args)
|
print(selected, scrollIndex, args)
|
||||||
end,
|
end,
|
||||||
@@ -103,3 +105,4 @@ RegisterCommand('testmenu', function()
|
|||||||
lib.showMenu('some_menu_id')
|
lib.showMenu('some_menu_id')
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|

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