Growing with the Web

Disabling the context menu with Dart

Published
Tags:

To disable the context menu on an element using Dart, simply add a listener to onContextMenu which calls e.preventDefault() to stop the event from bubbling up.

element.onContextMenu.listen((MouseEvent e) => e.preventDefault());

Comments

comments powered by Disqus
Like this article?
Subscribe for more!