How to detect mouse-down in web container

Hi. I’m trying to compile a Web app that was create with xojo2017 with the latest/greatest version of 2023. I have an issue for which I did not find a solution:
The application dynamically creates container controls and put them one under the other (visually I mean) to build something that looks like a flow. The container implements an event handler for the mouse-down event to make itself ‘selected’. I cannot find a corresponding event in the latest version.
Did I miss something ? Is there a work-around ?

While I know this isn’t your question, web 2 has the concept of flows built in. Any control that is a subclass of WebView can have its layout type set to Fixed or Flex. See:

Otherwise, put a rectangle in the background of your container and implement the Pressed event there.

1 Like

Unfortunately WebRectangle (API2) does not have a Pressed event.

I had the exact similar issue two weeks ago, porting an old Web Project to Xojo 2022r4.
Placing a WebCanvas in the background of the container (WebCanvas has a Pressed event) wasn’t a solution either because any WebLabel placed above the canvas would prevent clicking. And the WebContainer was full of labels.

I ended up using a WebButton to set the “selected” state.

Using onmousedown as Michel suggests is another solution.

Thanks. But seems the WebRectangle does not expose a ‘pressed’ event.

Thanks. Which Web component has ‘OnMouseDown’ ?

Thanks. Indeed. I tried to ‘bring to front’ the canvas, but then controls are hidden. There are other issues when trying to get the app to compile with latest version of xojo (controlsets are gone, same for webstyle, …) Seems it might be faster to rewrite the UI part.

All HTML elements support onmousedown. But this is accessible with JavaScript.

And how is it accessible?

It needs a javascript method that attaches the onmousedown to the element and sends back to the Xojo program.

If you never touched Javascript, perhaps it is better to use plain Xojo.

WebCanvas should be enough, but I’ve just made a simple Web SDK control you can put on top of the others. It has a Pressed event you can use.