showContextMenu method

Future<String> showContextMenu(
  1. List<String> actions,
  2. num x,
  3. num y
)

Implementation

Future<String> showContextMenu(List<String> actions, num x, num y) {
  completer = Completer();
  modalStatePanel.onClick.listen((event) {
    modalStatePanel.visible = false;
  });
  menuPanel.clear();
  for (final action in actions) {
    final actionElement = SimpleLabel()
      ..addCssClass('ContextMenuAction')
      ..caption = action;
    actionElement.nodeRoot.onClick.listen((event) {
      completer.complete(action);
      closeMenu();
    });
    menuPanel.add(actionElement);
  }
  menuPanel.nodeRoot.style
    ..top = '${y}px'
    ..left = '${x}px';
  modalStatePanel
    ..add(menuPanel)
    ..visible = true;
  return completer.future;
}