Responsive Text Controls

I’m looking for some advice on how to resize web controls and interlock their positions bassed on their size.

As an example you can see here that the text in a WebLabel wrapped when resized to a smaller width, which should automatically adjust the height of of the WebLabel. In turn, all elements below the WebLabel (in this case the Input fields) should move down.

I found some references to LayoutType, Flex, Flow, but I could not localize a documentation about how to use them, what they are for exactly and if they would address this issue.

So hopefully someone could shed shed some light on how to implement this correctly.

Thanks!

1 Like

Hi Louis. Have you seen this video? There are some LayoutType tips:

3 Likes

Hi @Ricardo_Cruz

Thank you so much for this video. I think I get the use case for the LayoutType / Flex Layout.

However, I don’t believe that this will solve my issue of a vertically “growing” TextBox (i.e. when the browser’s width is reduced) and the necessity that subsequent elements need to be repositioned.

Because even in the video, the child elements are all of fixed size.

This makes it very hard to have a simple responsive layout, since I have to size elements vertically for the smallest horizontal scenario. For example:

Will look like this in a wider enviroment:

Is that what it is or did I miss something in the video?

And thanks again for your response!
Louis

1 Like

That’s a real issue in Xojo Web. Every element’s size is fixed and positions are absolute. It makes it very hard to have a page grow vertically depending on the content’s dynamic size.

Unless I missed something too.

3 Likes

There isn’t an easy solution to “make the layout work like xojo’s locking mechanism” and “make the layout be responsive”. Trust me, I tried to figure that out for years.

What I usually suggest to users it to create different layouts for each size that you want to support.

I don’t know if @Brock_Nash is still around, but he made a lot of headway in this area in his own apps. You might be able to get some info from him.

1 Like

I have a few controls that support auto-expanding height and return an event to the Xojo code that allows for repositioning elements based on those changes. GraffitiLabel for example.

1 Like

Yes, this is my #1 issue with Xojo Web right now, causing me lots of headaches.
It enforces UI/UX limitations and compromises in basically every web app I currently work on.

I would like to be able to create web apps, with text fields, that dynamically grow/shrink vertically depending on the text length and width of the page.

As I understand, it could be solved by implementing 2 new features in Xojo Web, but maybe it’s not that simple?

  1. Have access to a text field that has no fixed height, so that its height varies dynamically depending on its width and text length and all the text in the text field is always visible. Height of the text field could simply be set to “*” in the IDE.

  2. Be able to set the top positioning of any/all other below elements on the page to be relative “position: relative;” instead of “position: absolute;”, maybe with a “*” as top in the IDE.

Would this be possible or is there more to it? @Ricardo_Cruz

2 Likes

Made a feature request for this https://tracker.xojo.com/xojoinc/xojo/-/issues/77753

1 Like

I’m not behind the IDE and just thinking oud loud…

Browser / Server
As far as I know is that with a Xojo web-app a lot of things happen browser-side and server side.

Due to efficiency the text control is handled by the browser. Dimensions and positions are dealt with by the server.
Changing the dimensions and positions, based on the value of the text control would have to be send to the server, that sends the proper dimensions back to the browser. This causes delays, obviously.
But I might be wrong here…

CSS / Bootstrap?
A solution is to use CSS.
Again, I’m just thinking out loud here… isn’t it possible to edit a Bootstrap theme, with a CSS class that deals with the dimensions?

Container Control
And maybe you could add a container control, or a rectangle, to help position other controls like a submit button or checkboxes.

Well, from what I can tell Xojo Web basically hard wires the positioning of every control with “position: absolute; height: Xpx; top: Ypx; etc.” and that kind of locks everything down.

Im hoping there is a way to change that so that we could maybe use “position: relative;” without specifying height and top, and that way gain dynamic height and top positioning of controls.

It would not affect any of the communication between the server and the browser, only the positioning of the controls.

Basically leave it to the browser to position the controls depending on the page size/dimension etc.

1 Like

I’ll try to come with an example to show a way to implement this. But yes, we all agree Web apps need an easy way to deal with this.

There isn’t an easy solution though, as @Greg_O said.

7 Likes

Some Layout controls and mechanism like in Wisej would be great.
Have a look at https://www.wisej.com

I’ve added a comment in #77753 with a sample project showing a way to do it.

It surely doesn’t covers every need, but I hope it helps.

Grabación de pantalla 2024-11-07 a las 12.08.21.mp4

6 Likes

Hi Ricardo, is there a place where I can get the source code of the web app example of the video ?

He mentioned is available on the case, here is the link:
https://tracker.xojo.com/xojoinc/xojo/-/issues/77753#note_586661

@Ricardo_Cruz Maybe a candidate to be included in Xojo’s Examples within the Choose a Project dialog?

2 Likes

The example included in the issues is not the one of the web app of the video

Are you looking at the one uploaded by Ricardo? (on that issue, I posted the direct link to Ricardo post)

Here is a screenshot of the IDE:

and here running:

it looks the same to me.

You need to download Ricardo’s sample:

maybe you don’t see that comment?

I’ve added another example to Issue #77753.

For convenience, you can grab them directly from this forum thread:

The second example shows how a container can also be added, nesting them. Could you guys please give it a try and explore using it?

If it makes sense, we could add some options to WebContainer to expose this behavior somehow, and make the IDE preview how it will look like at runtime.

5 Likes

Looks great at first impression. Im just about to start a new project, will implement this from scratch and let you know how it goes.

1 Like