Skip to content

Commit 9c9ba8a

Browse files
committed
Update README.md
1 parent a133148 commit 9c9ba8a

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ const myenum = {
133133
```javascript
134134
{
135135
type: 'BUTTON',
136+
name: 'Button',
137+
description: 'My favorite button.',
136138
onPress(button) {
137139
// code
138140
// you can update the button text as you please
139141
button.setText("hi!!")
140142
},
141-
name: 'Button',
142-
description: 'My favorite button.',
143143
}
144144
```
145145

@@ -260,6 +260,27 @@ const myenum = {
260260
}
261261
```
262262

263+
## `onInit` and `onDeinit`
264+
265+
Each visible option has the optional functions `onInit` and `onDeinit`.
266+
For example:
267+
```javascript
268+
{
269+
type: 'BUTTON',
270+
name: 'Button',
271+
description: 'My favorite button.',
272+
onPress() {
273+
console.log('Button presssed!')
274+
},
275+
onInit(gui) {
276+
gui.button.setText("(evil) Button")
277+
},
278+
onDeinit(gui) {
279+
console.log("the evil button will return someday!")
280+
}
281+
},
282+
```
283+
263284
## Name padding
264285

265286
On any option with a name visible, you can set the `noNamePadding` field to `true` to disable the padding.
@@ -331,11 +352,11 @@ const Opts = modmanager.registerAndGetModOptions(
331352
},
332353
myButton: {
333354
type: 'BUTTON',
355+
name: 'Button',
356+
description: 'My favorite button.',
334357
onPress() {
335358
console.log('Button presssed!')
336359
},
337-
name: 'Button',
338-
description: 'My favorite button.',
339360
},
340361
myInfo: {
341362
type: 'INFO',

0 commit comments

Comments
 (0)