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.

How to select images by clicking when editing web pages

Post Reply
webouse
Posts: 2
Joined: Thu Jan 18, 2024 4:15 am

How to select images by clicking when editing web pages

Post 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.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

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

Post 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.
webouse
Posts: 2
Joined: Thu Jan 18, 2024 4:15 am

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

Post 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.
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

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

Post by salvadordf »

Try executing JavaScript code to modify the width and height of the new IMG element.
Post Reply