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.

ElementBounds.x = TCefMouseEvent.x?(not by js)

coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by coater »

question 1.what is the difference between ICefDomNode.ElementBounds.x (.y) and TCefMouseEvent.x(.y) in the
ICefBrowserHost.SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer) .

Are they same value?
I find that ICefDomNode.ElementBounds.x + rect.x of CEFWindowParent1.ChildWindow = rect of a node in desktop.

question 2. If I use SendMessage, Which handle should be selected?
SendMessage(CEFWindowParent1.ChildWindowHandle , WM_LBUTTONUP, 0,makelong(X,Y) );
May be a render handle?


Even I use right rect.x and rect.y, but I still can not set cursor in a input box. what's the wrong?

devtools: the click can't captured by js event.
window.onclick = function(ev){
if(!ev){ev = window.event;} //
console.log("pageXY: "+ ev.pageX+"; "+ev.pageY);
console.log("offsetY: "+ev.offsetX+"; "+ev.offsetY);
console.log("screenXY: "+ev.screenX+"; "+ev.screenY);
console.log(ev.srcElement);
}

3.How to scroll a node into view by visit dom?

keen for your help, thank you!
Last edited by coater on Wed Apr 01, 2020 4:08 am, edited 1 time in total.
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by coater »

Now I know:
ElementBounds.x is relative to the upper left corner of the client area.

Message handle should be Browser.Host.WindowHandle.child.child!.
h1:= GetWindow(Chromium1.Browser.Host.WindowHandle,GW_CHILD);//chrome legacy window
h1:= GetWindow(h1,GW_CHILD);
Chromium1.Browser.Host.SetFocus(true);
SetCursorPos(X,Y);
SendMessage(h1 , WM_LBUTTONDOWN, 0,MAKELONG(x,y) );
SendMessage(h1 , WM_LBUTTONUP, 0, MAKELONG(x,y) );
Using sendmessage will get right click event.

but I still confused by ICefBrowserHost.SendMouseClickEvent(const event: PCefMouseEvent; kind: TCefMouseButtonType; mouseUp: Boolean; clickCount: Integer) . I can obtain click event, but not at right position.
I can't find out what is the right TCefMouseEvent.x(.y)!

And I don't know How to scroll a node into view by domvisit.

May someone help me, thank you!
Last edited by coater on Wed Apr 01, 2020 4:08 am, edited 1 time in total.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by salvadordf »

You can scroll to an element using JavaScript :
https://stackoverflow.com/questions/500 ... javascript

Use the SimpleOSRBrowser demo to get the mouse coordinates for TCefMouseEvent.

For the SimpleOSRBrowser tests I would set the Windows scaling to 100% (96 DPI), use only one monitor and I would also set the browser window in the top-left corner of your application. It would be even easier if you hide the application borders, menu items, etc. and run the demo in the top-left corner of your screen. That way all coordinate systems are the same and you can concentrate on other tasks.
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by coater »

Thank you very much!
If there are some ways to control scrollbar? (not by JS)
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by salvadordf »

You can set the focus in the browser and simulate the mouse wheel or key presses that make the page scroll (Page up, Page down, Space, Home, End, etc.)
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by coater »

Thank you very much!
It is difficult to control node to scroll to visible area by Key event or mouse event!
There is no way to control sroll bar internal?
Duhon
Posts: 1
Joined: Wed Apr 01, 2020 12:07 pm

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by Duhon »

Is there no way of making controlling the scroll easier at all?
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by salvadordf »

I'm sorry but I'm not aware of any other methods to scroll the page with CEF.

You will have to use JavaScript or simulate mouse events with Windows messages or using TChromium.SimulateMouseWheel as you can see in this thread in the official CEF forum :
https://www.magpcss.org/ceforum/viewtop ... =7&t=15187

The JSEval demo has the code to get the scrollbar position.
coater
Posts: 135
Joined: Sat Sep 29, 2018 1:51 pm

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by coater »

Thank you very much! It may be better to add a srollintoviw attribute to domnode.

If there are some examples about GetElementAttributes(aIStrMap);? I cannot get all attributes.

Code: Select all

      
      aIStrMap  := TCefStringMapOwn.Create; //uses uCEFStringMap
            aEle.GetElementAttributes(aIStrMap);
            aNodeStr := '' ;
            for j := 0 to aIStrMap.Size -1 do
               begin
                  aNodeStr := aIStrMap.Key[j]   + '|'  +  aIStrMap.Value[j]  + '|' ;
               end;
            aNodeStr := '|tag|' + aEle.ElementTagName+ '|'+ aNodeStr;  
Last edited by coater on Fri Apr 03, 2020 5:33 am, edited 1 time in total.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: ElementBounds.x = TCefMouseEvent.x?(not by js)

Post by salvadordf »

Try using a TStringList with TDomNode.GetElementAttributes like this :

Code: Select all

MyEle.GetElementAttributes(TStrings(MyStringList));
There's only one example using a TCefStringMapOwn here :
https://github.com/salvadordf/CEF4Delph ... e.pas#L122
Post Reply