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.

middle mouse button

Post Reply
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

middle mouse button

Post by kotyara »

How to assign your own action to the middle mouse button click?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: middle mouse button

Post by salvadordf »

If you're using a browser in "normal" mode then try intercepting the Windows message using the TChromium.OnRenderCompMsg event.

If your application uses the OSR mode then all you have to do is implement your code in the OnMouseUp or OnMouseDown events of the buffer panel.
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

Re: middle mouse button

Post by kotyara »

How do I know which Chromium triggered this event?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: middle mouse button

Post by salvadordf »

In case of OSR browsers you should have a one to one relation between a buffer panel and a TCromium component.
If you get a OnMouseDown event in that buffer panel then you know it's related to the only browser using that panel.
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

Re: middle mouse button

Post by kotyara »

I'm trying to do this:

Code: Select all

Chromium->OnRenderCompMsg = RenderCompMsg;

Code: Select all

void __fastcall TForm1::RenderCompMsg(Winapi::Messages::TMessage &aMessage, bool &aHandled){
	if(aMessage.Msg==WM_MBUTTONDOWN){
		aHandled = true;
		// ??? 
	}
}
But I don't understand how to understand what Chromium it caused =(
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: middle mouse button

Post by salvadordf »

Sorry. I though you were using the OSR mode.

In normal mode you would assign a different procedure to handle the OnRenderCompMsg event of each browser.
I see now that I should add a "Sender" parameter to those events to make this easier.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: middle mouse button

Post by salvadordf »

Please, download CEF4Delphi again from GitHub.

I just uploaded a new CEF4Delphi version and now all TChromium events have a "Sender" parameter, including "OnRenderCompMsg".

Use "Sender" like this to know which browser triggered that event :

Code: Select all

TChromium(Sender).BrowserId
Each browser has a unique "BrowserId" property.
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

Re: middle mouse button

Post by kotyara »

Thank you very much.
Post Reply