Morfik Tips: How to disable the right-click context menu
March 21, 2006Many times you don’t want the user to right-click in your xApp or want to use the righ-click for some other purpose than popping up the browser’s context menu. How?
You will have to add the following code to the application’s source code in order to disable the browser’s default context menu.
- First in Morfik, click on the Project tab in the main window’s upper left corner. Then in the bottom tab row select Browser to see the client source code of the application.
- Then add the following to the class declaration in the Interface section:
Unit mfkMineSweeperXApp;
Interface
Type
mfkMineSweeperXApp= Class(TXApp)
Published
{ Events }
Private
{ Private declarations }
Public
{ Public declarations }
Constructor Create;
End;
- Now in the implementation section add the following:
Implementation // Avoid default right-click context menu Function NoContextMenu(Event: TDOMEvent): Boolean; Begin Result := False; End; Constructor mfkMineSweeperXApp.Create; Begin Inherited Create; //PI20060321: for R0.8.4.x and before use SysWinHandle instead of Window Window.Document.OnContextMenu := @NoContextMenu; End;
