Page 1 of 1

Right click is not blocked

Posted: Mon Mar 30, 2020 12:51 pm
by dilfich
Hi!
How do I completely prohibit right-click on a document?

Code: Select all

BeforeContextMenu
model.Clear;
This does not help, only removes the context menu and the click on the page passes.

Re: Right click is not blocked

Posted: Tue Mar 31, 2020 7:57 am
by salvadordf
Try adding this JavaScript code to the document :
https://stackoverflow.com/questions/737 ... y-web-page

You can also try intercepting the windows message for the right mouse button using the TChromium.OnRenderCompMsg event.

Re: Right click is not blocked

Posted: Tue Mar 31, 2020 8:49 am
by dilfich
All options via JavaScript disable only contextmenu and the click still passes, this is the first thing I tried.
RenderCompMsg
I've tried it too but it either doesn't work or I'm doing something wrong.

Code: Select all

aHandled:= True;
Disables the mouse completely.

Code: Select all

if (aMessage.Msg = WM_RBUTTONDOWN) then aHandled:= True;
The mouse still works, isn't it right?

Re: Right click is not blocked

Posted: Tue Mar 31, 2020 11:00 am
by salvadordf
dilfich wrote: Tue Mar 31, 2020 8:49 am

Code: Select all

if (aMessage.Msg = WM_RBUTTONDOWN) then aHandled:= True;
The mouse still works, isn't it right?
That code should block the WM_RBUTTONDOWN messages only, leaving all other mouse messages pass through.

Re: Right click is not blocked

Posted: Tue Mar 31, 2020 11:11 am
by dilfich
Yes, it kind of works if you check it like this.

Code: Select all

document.addEventListener("mousedown", function(evt) {
      console.log(evt.clientX+':'+evt.clientY +':'+ evt.buttons);
});
But this does not work on a real site and the site somehow registers that a click was made. :(