mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
add radial menu typescript examples
This commit is contained in:
1 parent
93f514f1f2
commit
41a1a7cf1b
1 file changed
+137
@@ -2,10 +2,30 @@
|
|||||||
title: Radial Menu
|
title: Radial Menu
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.addRadialItem
|
### lib.addRadialItem
|
||||||
|
|
||||||
Item or array of items added to the global radial menu.
|
Item or array of items added to the global radial menu.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.addRadialItem(items)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.addRadialItem(items)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
* id: `string`
|
* id: `string`
|
||||||
* Id that is used for removing options.
|
* Id that is used for removing options.
|
||||||
* icon: `string`
|
* icon: `string`
|
||||||
@@ -18,12 +38,46 @@ Item or array of items added to the global radial menu.
|
|||||||
|
|
||||||
Id of an item to be removed from the global menu.
|
Id of an item to be removed from the global menu.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.removeRadialItem(item)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.removeRadialItem(item)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
* id: `string`
|
* id: `string`
|
||||||
|
|
||||||
### lib.registerRadial
|
### lib.registerRadial
|
||||||
|
|
||||||
Registers a radial sub menu with predefined options.
|
Registers a radial sub menu with predefined options.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.registerRadial(radial)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.registerRadial(radial)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
* id: `string`
|
* id: `string`
|
||||||
* Unique menu id used to open with `menu` prop on an item.
|
* Unique menu id used to open with `menu` prop on an item.
|
||||||
* items: `array`
|
* items: `array`
|
||||||
@@ -37,6 +91,23 @@ Registers a radial sub menu with predefined options.
|
|||||||
|
|
||||||
Hides the radial menu if one is open.
|
Hides the radial menu if one is open.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.hideRadial()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.hideRadial()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
### Usage Example
|
### Usage Example
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -48,6 +119,9 @@ as long labels will look out of place and should not be used with the radial men
|
|||||||
|
|
||||||
Here's a use case example with some global options and an option utilising the lib's points system.
|
Here's a use case example with some global options and an option utilising the lib's points system.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.registerRadial({
|
lib.registerRadial({
|
||||||
id = 'police_menu',
|
id = 'police_menu',
|
||||||
@@ -116,5 +190,68 @@ function point:onExit()
|
|||||||
lib.removeRadialItem('garage_access')
|
lib.removeRadialItem('garage_access')
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
Points system in the lib isn't available for the npm package.
|
||||||
|
:::
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.registerRadial({
|
||||||
|
id: 'police_menu',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: 'Handcuff',
|
||||||
|
icon: 'handcuffs',
|
||||||
|
onSelect: () => {
|
||||||
|
console.log('Handcuffs')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Frisk',
|
||||||
|
icon: 'hand'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Fingerprint',
|
||||||
|
icon: 'fingerprint'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Jail',
|
||||||
|
icon: 'bus'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Search',
|
||||||
|
icon: 'magnifying-glass',
|
||||||
|
onSelect: () => {
|
||||||
|
console.log('Search')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
lib.addRadialItem([
|
||||||
|
{
|
||||||
|
id: 'police',
|
||||||
|
label: 'Police',
|
||||||
|
icon: 'shield-halved',
|
||||||
|
menu: 'police_menu'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'business_stuff',
|
||||||
|
label: 'Business',
|
||||||
|
icon: 'briefcase',
|
||||||
|
onSelect: () => {
|
||||||
|
console.log('Business')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||

|

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