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)
ElementBounds.x = TCefMouseEvent.x?(not by js)
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!
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.
Re: ElementBounds.x = TCefMouseEvent.x?(not by js)
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!
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.
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: ElementBounds.x = TCefMouseEvent.x?(not by js)
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.
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)
Thank you very much!
If there are some ways to control scrollbar? (not by JS)
If there are some ways to control scrollbar? (not by JS)
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: ElementBounds.x = TCefMouseEvent.x?(not by js)
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)
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?
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)
Is there no way of making controlling the scroll easier at all?
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: ElementBounds.x = TCefMouseEvent.x?(not by js)
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.
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)
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.
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.
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: ElementBounds.x = TCefMouseEvent.x?(not by js)
Try using a TStringList with TDomNode.GetElementAttributes like this :
There's only one example using a TCefStringMapOwn here :
https://github.com/salvadordf/CEF4Delph ... e.pas#L122
Code: Select all
MyEle.GetElementAttributes(TStrings(MyStringList));
https://github.com/salvadordf/CEF4Delph ... e.pas#L122