Xojo Web2 Widget: Accordion

Underwriters Technologies is making an internal tool we use available to the entire Xojo community. This tool, called “Accordion” solves a couple of problems…

  1. We got tired of Pixel pushing trying to get everything so neatly spaced. The IDE it’s fine if you want to use it’s predefined gaps between things but if you need things tighter, you know that lining up labels and moving things around is a pain in the neck.

  2. When trying to add a checkbox, that triggered an additional control. For example, on an application for employment there might be a question “Have you ever committed a felony.” But there is no reason to take a screen real estate with the text area that says "Please provide more information. Unless the checkbox was checked.

It works on the concept of lines of Controls.

It starts on the top with a variable that defines how many pixels down you want to come.

It’s and goes through every control on the page, looking for the one closest to the
If it finds two of them that are the same height assumes that they are one line.

Be sure to use the align tool or look at the top property in the inspector. As you will see in the enclosed demo, one pixel off causes radical spacing of Controls.

And then measures the height of the control, and adds the appropriate number of pixels between that control on the next line.

I’ll put it up here for a little while:
Dropbox - UT Accordian.xojo_binary_project.zip - Simplify your life]

Feel free to use it, extend it, do whatever. Keep in mind that we make no warranties, no promises, that it will work or we will continue to support it at all. If you want to use it you do so at your own risk. But it’s free. You get what you pay for

PS this would be a whole lot cooler, if bug 66828 was resolved.

Special thanks to: Alberto DePoo on this one! He refactored and improved the code after he found me screaming obscenities at my mac/Xojo.

For what it’s worth we also have it working in Web 1.0. If you want to see it live:


Thanks for sharing!

1 Like