Hi, I launch the example project “"DesktopScrollableArea” and I watch the video New DesktopScrollableArea control + New DesktopToolbar features .
I didn’t reach to read and/or write the content of TextField1 . How can we access to the controls of the container inside the ScrollableArea?
When it is a simple container, I do MyContainer1.Mycontrol.value but I can’t here.
I tried “ScrollableArea1.MyContainer.TextField1.Text” but that’s not accepted.
Does not exists in Examples for the current Xojo (2026r2) version…
…unless Sherlock is doing some wrongs…
According to the documentation a DesktopScrollableArea has a property Container that gives you access to the scrolled container.
1 Like
Just cast the container property of the ScrollableArea to the container Type and set the controls scope inside the container as public.
1 Like
I’ve modified the example to show how it’s done.
Create a property of your container’s type, instantiate it, and set the DesktopScrollableArea’s Container property to your instance.
Then you can access the controls on that property instance directly.
ScrollableContainer2.xojo_binary_project.zip (10.7 KB)
2 Likes
It would be ScrollableArea1. ContainerProperty.TextField1.Text
Create your container, name it MyContainer.
Add TextField1 control to the MyContainer container.
Right-click the window, select to create a new property.
Name = ContainerProperty
Type = MyContainer
…
In your code, like on the Opening() event for that window, use the following code:
ContainerProperty = New MyContainer
ScrollableArea1.Container = ContainerProperty
Then, say, in the Pressed() function for your button, you might have this code:
ScrollableArea1.TextField1.Text = “Person”
ContainerProperty.TextField1.Text = “Person”
Another button’s code might contain:
ScrollableArea1.TextField1.Text = “Animal”
ContainerProperty.TextField1.Text = “Animal”
… I’m just spitballing it on here, so if someone else can improve this, PLEASE DO SO
I updated the project further to show you how the text can be changed, see the code for the buttons that swap out the text content right after the containers are swapped.
ScrollableContainer_swapText.zip (29.7 KB)
This should hopefully address your question!
Admins / staff on here, feel free to add my project sample on here as a ScrollableArea sample project.
And here is the link to an Issue I created regarding no sample project:
https://tracker.xojo.com/xojoinc/xojo/-/issues/81658
so if anyone wants to upvote the inclusion and/or contribute their own sample project.
2 Likes
Or set the controls to private and provide methods (of the container subclass) for updating the controls’ content (arguably a cleaner approach).
2 Likes
Thank you very much. I don’t understand why it is not as simple as when we add a simple Container.
I don’t even bother using the “DesktopScrollableArea.”
It’s not native on macOS and definitely doesn’t feel right for macOS users (in fact it feels incredibly funky and unnatural). For macOS, it’s still best to use NSScrollView (which is very easy with MBS plugins).
Wake me up when Xojo Inc implements this correctly (natively) for macOS and Windows. In the meantime, for those who wants their macOS look/behaves as it should, I made a small example for the NSScrollView.:
NSScrollViewExample.xojo_binary_project.zip (13.9 KB)
5 Likes
Because containers are of a specific size, the ScrollableArea gives you an object to effectively mask that larger object in a smaller footprint with scrollbars. And because you can declare which container will fill the scrollable area upon instant demand, you can swap out containers.
This is very useful for preferences panels where each section (really a container populated from a preferences file or settings stored somewhere) shows up within the space and the sections that are “too large” can simply be scrolled.
Another use is a kanban board app.
The uses are almost endless, and I personally have been waiting for this feature to be implemented. This couldn’t have happened at a more perfect time for me.
4 Likes
Amy, thanks for sharing the project.
Henry
1 Like