Reputation: 149
How to block middle mouse click on the links in TChromium?
I want to handle this middle mouse click by my own to open it in new tab, so i need to block this middle mouse click in TChromium, and then hook middle mouse, and then open selected link in new tab.
I have this default function:
function TCustomRenderProcessHandler.OnBeforeNavigation(const browser: ICefBrowser;
const frame: ICefFrame; const request: ICefRequest;
navigationType: TCefNavigationType; isRedirect: Boolean): Boolean;
begin
Result:=False;
end;
But exactly it gives nothing.
TNX
Upvotes: 1
Views: 762
Reputation: 149
I did it by some another way.
@TLama, thanks for fast working Hook Function.
So, how i did it:
//@HOOK PROC
function MouseProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
HookStruct: TMouseHookStruct;
begin
HookStruct := PMouseHookStruct(lParam)^;
if (nCode >= 0) then
begin
case wParam of
WM_MBUTTONDOWN:
Begin
MiddleDown := True;
LeftMouse := False;
End;
WM_LBUTTONDOWN:
Begin
MiddleDown := False;
LeftMouse := True;
End;
WM_RBUTTONDOWN:
Begin
MiddleDown := False;
LeftMouse := False;
End;
end;
end;
Result := CallNextHookEx(0, nCode, wParam, lParam);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
If(MiddleDown) then
Begin
MiddleDown:=False;
If(SelectedItem<>'') Then
Form1.AddNewTab(SelectedItem,SelectedItem,'');
End
Else If(LeftMouse) then
Begin
LeftMouse:=False;
If(SelectedItem<>'') Then
FBrowsers[Current_FBrowser_Index].Load(SelectedItem);
End;
end;
function TCustomRenderProcessHandler.OnBeforeNavigation(const browser: ICefBrowser;
const frame: ICefFrame; const request: ICefRequest;
navigationType: TCefNavigationType; isRedirect: Boolean): Boolean;
begin
if navigationType = NAVIGATION_LINK_CLICKED then
begin
Result := True;
end
else
Result := False;
end;
So, thats how it works in my DCEF3 :)
Thanks to all for help!!!
Upvotes: 1