Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Right click is not blocked

Post Reply
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Right click is not blocked

Post 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.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Right click is not blocked

Post 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.
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Right click is not blocked

Post 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?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Right click is not blocked

Post 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.
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Right click is not blocked

Post 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. :(
Post Reply