Making a Control Array

WOW… talk about making something easy … into something Difficult

A simple control array.
In RealStudio

  1. Drop a control into your Window
  2. set its index to 0
  3. copy the control
  4. paste it…
  5. Voila! you have Index 1
  6. repeat 4-5 until you have the number of controls you need.

In XOJO

  1. Drop a control into your Window
  2. Scratch you head trying to figure out where INDEX is… OH it isn’t there!
  3. finally figure out you need to click on CONTROL SET
  4. have INSPECTOR blitz out and go blank on you… yeah BLANK
  5. suffer a headache while you try and figure out what you may have lost
  6. click on the control in NAVIGATOR (click on the control in the window does no good)
  7. Breathe a sigh of relief when INSPECTOR comes back … and new control is there
  8. Realize that Xojo incremented the INDEX by TWO, not by one
  9. manually reset index to correct value
  10. repeat steps 3 to 9 …

And this thing was Beta tested???

Worst thing… is I seem to be stuck with Xojo … since if I try to load this project back with RS2012… all I get is a blank screen there…

Was. And this was reported. But the package was closed for launch before the fix. Report 26780.

[quote]Worst thing… is I seem to be stuck with Xojo … since if I try to load this project back with RS2012… all I get is a blank screen there…
[/quote]
This is supposed to work. Attach the project to a private case so they can figure out what’s wrong.

I tested same on Mac Version.
I tried Canvas object. Option Drag. Created some canvases are 0,2,4,6… Indexs
Then I selected all objects, and I see Index Box is multiple, after set number i.e. 0 or 1
Selected release.

This changes index number 0,1,2,3,4,…

Also at multiple text show, If I input No. 4 or 5 makes 4,6,7,8,9,or 5,6,7,8,9,10…

This is useful.

But this is bug maybe.

///////
I see now!
Oh I lost reading it is reported and fixed. Sorry.

The case 26780 is not fixed yet, just acknowledged and put in the queue for the fix.

Thank you Rick. I can understand.

would it be too much to ask that you actually explain these new methods in the documentation? search “control set” in all help and get nothing. also, please explain how this is better than the old way of typing a 0 thin index field?

I’ll try to help. Open the User Guide, book 2, User Interface, section 16 (after page 102). Questions like “why things changed”, only Xojo team can answer.

thanks. i don’t understand why i don’t get any results when i search “control sets” in the pdf? RB documentation has always been a problem. i like new and better things. i just need to be able find the docs on how to implement. i use the language reference primarily. type control sets you get zilch. search control arrays you get a page that has been deleted. you have go back real studio docs to learn to handle a control array in code. frustrating

A ContainerControl is not a real control. You cannot make a control array of containers.

yes, that surprised me but I’ve just tried it out and doesn’t seem you can. Thats very limiting, why would it not be possible to make a control array with a container.

Correct me if I am wrong but in VB you could load a control at runtime and add it to your control array. Is this possible in Xojo?

Apples and oranges. Desktop control arrays are deeply embedded in the essence of being a “control”. Container controls were bolted on later and are more like windows than controls. You can’t even access a desktop container from the Window’s list of controls. It feels very kludgy in some ways. Web controls are a different beast altogether. They are similar to their desktop counterparts in function only. Web controls and web containers were developed at the same time, so they had more freedom to make them more consistent.

Yes. That’s kind of the point of a desktop control array. You can do the same thing with containers, but via a different mechanism.

Now that container controls come with every version of Xojo, why would you want a control array? Have they changed and are ‘real’ control arrays or are they still the same hack as they were in RB?

Why do you say control arrays are/were a “hack”… and how does container controls remove the “need” for control arrays?

A control array is an indexed collection of like type controls that share some relationship… radio buttons are a great example.

where a container control allows you to group any type of controls (I’ve never used them, but my impression is they are similar to page-panels). and if that is the case, then they are far from being the same or similar functions

Jim, What? That does not make sense. Say I use a container control to make a custom control which has a property backcolor. I may want 10 instances of my custom control on one window and want to change the backcolor of each one at the same time. If they are in a control array this is easier than referring to each one individually.

A container control does not in any way shape or form remove the need for using control arrays.

What has a container got to do with control arrays? Nothing…

Both Control Sets (formally Control Arrays) and ContainerControls allow you to add controls to a window at run-time. ContainerControls have the added benefit of being able to add a group of controls all at once.

Control Sets let you use the index property to easily manage multiple copies of the same control. You could mimic this with ContainerControls by managing them in your own array, I suppose.

Control Sets still have their uses, but don’t avoid ContainerControls. They are very powerful and are a great way to simplify a UI layout.

[quote=18640:@Dave S]Why do you say control arrays are/were a “hack”… and how does container controls remove the “need” for control arrays?

A control array is an indexed collection of like type controls that share some relationship… radio buttons are a great example.

where a container control allows you to group any type of controls (I’ve never used them, but my impression is they are similar to page-panels). and if that is the case, then they are far from being the same or similar functions[/quote]

You will have to ask the programmers why there were or possibly still are a hack, I didn’t write the code for them.

I know very well what a control array is, and wouldn’t use one, a container control does the job and much better.

Paul I agree. I use a container control for my SourceView class. Originally I used a canvas control but the scrollbar for it had to be external to the SourceView and I had to interact with it through events and properties. Since Xojo and the container being available under all licences I use the container control instead of the canvas and have the scrollbar within my container so from the users point of view there is no work to do in tying the scrollbar to the sourceview.

I was a little bit disappointed to recently realise though that you cant have a container as part a control array (Control Set). This does seem a little bit inconsistent as the container should be treated as just another control. What is the thinking behind this?

[quote=18736:@Mike Charlesworth]Jim, What? That does not make sense. Say I use a container control to make a custom control which has a property backcolor. I may want 10 instances of my custom control on one window and want to change the backcolor of each one at the same time. If they are in a control array this is easier than referring to each one individually.

A container control does not in any way shape or form remove the need for using control arrays.

What has a container got to do with control arrays? Nothing…[/quote]

Thanks for your opinion but it makes total sense. A container control in many ways, shapes and forms remove the need for using control arrays which aren’t arrays to begin with.

Maybe instead of making these statements you should ask for clarification.

You want an array of container controls, make one - which would be a real array.

Add a property to the window MyCC() As MyContainerControl
Add an instance to both the window and MyCC and now you can use MyCC just like you would anything else.

Ok Jym can you clarify for me please as I can not see the connection. I need 10 buttons on a window and want to change their caption at the same time to the same text. Simple Create 10 buttons in a control set indexed 0 to 9 and then change caption as appropriate. How does a container help me do this any easier.

All I was saying is that, to me, a control set (Array) fulfils a completely different task to a container. I cannot see the correlation. You stated:

but I don’t understand this statement?