new GUI()
.add({ value: () => console.log('foo') }) // Auto detect
.add({ field: 'method' }) // Specify field name
.add({ field: new MethodField() }) // Provide field instance
You can specify additional subfields controlling method arguments:
new GUI()
.add({
label: 'Add',
value: (a, b) => alert(a + b) ,
args: [{ value: 1 }, { value: 2 }]
// Array of the same parameters you would give to add a field// Here we take advantage of auto-detection of number values// so we'll get the right field types
})
Method field
new GUI() .add({ value: () => console.log('foo') }) // Auto detect .add({ field: 'method' }) // Specify field name .add({ field: new MethodField() }) // Provide field instance
You can specify additional subfields controlling method arguments:
new GUI() .add({ label: 'Add', value: (a, b) => alert(a + b) , args: [{ value: 1 }, { value: 2 }] // Array of the same parameters you would give to add a field // Here we take advantage of auto-detection of number values // so we'll get the right field types })
Preview