Page 1 of 1

How to select images by clicking when editing web pages

Posted: Thu Jan 18, 2024 4:23 am
by webouse
In the demo EditorBrowser, I inserted an image and need to implement the following function: click on the image, and then you can operate on it, such as deleting, dragging and dropping.

Does anyone know how to do it.

thanks.

Re: How to select images by clicking when editing web pages

Posted: Thu Jan 18, 2024 1:54 pm
by salvadordf
Hi,

That demo executes this deprecated JavaScript command to edit the text and insert images : document.execCommand.
https://developer.mozilla.org/en-US/docs/Web/API/document/execCommand

You can also use the experimental Input.dispatchKeyEvent DevTools method :
https://chromedevtools.github.io/devtools-protocol/1-3/Input/#method-dispatchKeyEvent

The DevTools method is used by the EditorBrowser demo for WebView4Delphi and it also works fine.

Re: How to select images by clicking when editing web pages

Posted: Fri Jan 19, 2024 5:47 am
by webouse
Thank you for your reply.

I have tested the EditorBrowser demo for WebView4Delphi, but it did not meet my requirements.

Is there any other way to select an image with a mouse click and adjust its size.

Re: How to select images by clicking when editing web pages

Posted: Sat Jan 20, 2024 5:09 pm
by salvadordf
Try executing JavaScript code to modify the width and height of the new IMG element.