Page 1 of 2

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

Posted: Mon Mar 30, 2020 4:34 am
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!

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

Posted: Tue Mar 31, 2020 1:38 am
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!

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

Posted: Tue Mar 31, 2020 8:08 am
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.

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

Posted: Wed Apr 01, 2020 12:56 am
by coater
Thank you very much!
If there are some ways to control scrollbar? (not by JS)

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

Posted: Thu Apr 02, 2020 9:03 am
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.)

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

Posted: Thu Apr 02, 2020 10:03 am
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?

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

Posted: Thu Apr 02, 2020 12:06 pm
by Duhon
Is there no way of making controlling the scroll easier at all?

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

Posted: Thu Apr 02, 2020 12:26 pm
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.

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

Posted: Thu Apr 02, 2020 3:21 pm
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;  

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

Posted: Thu Apr 02, 2020 7:00 pm
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