-
-
Notifications
You must be signed in to change notification settings - Fork 126
ContextMenu
Marc Espín Sanz edited this page Jun 23, 2020
·
4 revisions
With the ContextMenu constructor you can create floating menus inside Graviton.
Example:
function entry(API){
const myContextMenu = new API.ContextMenu({
list: [
{
label:'Option 1',
action(){
console.log('Clicked option 1')
}
}
],
parent: document.body,
x: 100,
y: 100
})
}
You must pass an object with some properties:
- list: list of buttons showed in the context menu
- parent: DOM element where the context menu will be inserted
- x (use if you don't pass an event): custom x position
- y (use if you don't pass an event): custom y position
- event (use if you don't pass x neither y): it will be shown where the user clicked by using the Event object
Example using event instead of x and y:
function entry(API){
document.getElementById('App').onclick = e => {
const myContextMenu = new API.ContextMenu({
list: [
{
label:'Option 1',
action(){
console.log('Clicked option 1')
}
}
],
parent: document.body,
event: e
})
}
}
Documentation
Tutorials
Contributing
About