3

How can the context menu in the TEdgebrowser component be overwritten? The property inspector does not offer an event for this.

USauter
  • 295
  • 1
  • 9
  • Most likely you can't - [How to disable TWebBrowser context menu?](https://stackoverflow.com/q/68452073/4299358) had no answer to this either. – AmigoJack Aug 26 '21 at 17:12
  • @AmigoJack For this article [How to disable TWebBrowser context menu?](https://stackoverflow.com/questions/68452073/how-to-disable-twebbrowser-context-menu), , I posted the solution. – USauter Aug 27 '21 at 05:49
  • Welcome to Stack Overflow: it works with questions and answers. In contrast to comments an answer has much more space, i.e. to post actual code and explanations. I'm pretty sure your comment will be easily overseen, let alone worthless once the linked resource no longer exists. – AmigoJack Aug 27 '21 at 07:56

1 Answers1

1

The context menu can be deactivated using Javascript. This solution does not cover all use cases. It's enough for my problem..

<!DOCTYPE html>
<html lang="de">
  <head>
  <title>Test</title>
  <script type='text/javascript'>
    let ContextMenuDefault = false;  
    document.addEventListener('contextmenu', function(event)
    {
      if (false == ContextMenuDefault)
       event.preventDefault();
    }, true);
  </script> 
  </head>   
  <body>
   Hello World
  </body>
</html> 
USauter
  • 295
  • 1
  • 9