A
A
anton8782015-11-15 21:27:49
JavaScript
anton878, 2015-11-15 21:27:49

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);

Further. How to make it so that when you right-click on an item and select the desired option from the menu, you can change, for example, the css of this item?
upd: HTML page -> ul li list is laid out on it -> Right-clicked on one of the items of this ul li list on this html page -> gui.Menu context menu appeared -> clicked on "Make red" in gui. Menu -> that li item (which is on the page with html) turned red.
ps jquery connected

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2015-11-15
@k12th

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 question

Ask a Question

731 491 924 answers to any question