Answer the question
In order to leave comments, you need to log in
How to work with block via gui.Menu node-webkit?
Let's say there is a ul list with several items.
This each li item of this list has its own id, which can be absolutely anything.
Then there is the code (in order not to spread all my own, I took it from a random site, but the essence is the same):
// Создать пустое меню
var menu = new gui.Menu();
// Добавить в него пункты или разделители
menu.append(new gui.MenuItem({ label: 'Ничего не делать' }));
menu.append(new gui.MenuItem({ type: 'separator' }));
// .. и повесить на них обработчики
menu.append(new gui.MenuItem({
label: 'Сказать "Привет!"',
click: function() {
alert('Привет!')
}
}));
// Показывать в виде контекстного меню
document.body.addEventListener('contextmenu', function(e) {
e.preventDefault();
// В том месте, где мы кликнули
menu.popup(e.x, e.y);
return false;
}, false);
Answer the question
In order to leave comments, you need to log in
gui.Menu has nothing to do with HTML, knows nothing about CSS/li/id. If you want to style the context menu, you will have to do it the old fashioned way, with layout :(
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question