Control Arrays (and events)

If I drag and drop a subclass of shell onto my application can I turn that into an array of shells?
If so is there a new parameter to the data available and completed events?
Can someone explain control sets?

Yes, you can make your shell subclass into an control set and it does add an index as integer parameter to the events.

A control set is a group of like controls that have the same name and share event code. You can address them by index, similar to an array.

MyTextArea(1).Text = “foo”

Using a control array can simplify your code in certain cases. It also reduces clutter in the navigator. My most frequent use of control sets is for labels. They don’t have any event code, but it packs them all under one entry.

How do I add an new shell to the pool?
dim MyQuery as new AQuery 'AQuery isa shell
mQueryPool.Append(MyQuery)

So a couple of things…
WebPage1.mQueryPool.Name Layout (property name) Syntax error Name
WebPage1.Button1.Action, line 12 This item does not exist
mQueryPool.Append(MyQuery)

I’m sure that the issue some how is that there is a bug in the IDE…

I think it’s time for a bug fix in the IDE.
Control arrays don’t work.
It’s too bad because my code was finally looking right now I have to do all sorts of work arounds to addhandlers for each event of each instance I create. Messy Messy Messy.

Control sets (not called control arrays anymore) work - no problems here. Can you be more specific or post some code?

For control set when you use events there is no problem with code wrote in it, when you use addHandler for events then you have to set the addHandler for every control you add.

I see no problem with this

[quote=63857:@Brian O’Brien]WebPage1.mQueryPool.Name Layout (property name) Syntax error Name
[/quote]
So I should ignore this compiler error?
I think not.

Yes.

Yes, index As Integer

That is explained in the user’s guide - and your job, not ours!

I created a control set on a window and turned it into a control set. No problem. I get the two event handlers:

Sub Completed(index As Integer) Sub DataAvailable(index As Integer)
It clearly works.

[quote=63867:@Brian O’Brien]I think it’s time for a bug fix in the IDE.
Control arrays don’t work.
It’s too bad because my code was finally looking right now I have to do all sorts of work arounds to addhandlers for each event of each instance I create. Messy Messy Messy.[/quote]
Yes, I agree, control sets are unusably buggy, which makes it pathetic; with no rudeness intended to the Xojo team.

Ah, you want to create them dynamically. That is not supported for non-control classes - the ones that live on the pasteboard. But then, it hardly makes sense to do it that way, anyway. Why use a control set for something that isn’t a control?

the events being in the window.

Tim:

I do that regularly with classes which are not subclasses of UI-controls. No problems doing that. If you have a ClassA (a subclass of object for example) and you add an instance onto a window and you name it ObjectA, you then can create more of them like that:

Dim unused As ClassA = New ObjectA()

This object will be shown in the debugger’s window content section as:

ObjectA$0 ObjectA$1 etc.
I have to say, I’ve never had any troubles with control sets (desktop apps only).

Indeed I wan’t a set of objects UI or Not to be able to generate an event with an index on the winow that the events are destined for.
I don’t see why this is such an issue. It really seems like an IDE bug to me… and dare I say one that has existed since pre xojo.

There are no issues if done right, really.

Perhaps I remembered incorrectly, but I thought I recalled a Xojo engineer say it wasn’t intended to work that way. I can’t find that conversation now, so maybe it never happened. In any case, it would make a good bug report / feature request, depending on Xojo’s intent.

I can’t test it at the moment, but there are some difference with controls sets between desktop and web apps. One may be that web apps (which is what Brian is using here) cannot have control sets of non-controls.

It’s a pitty that there is a diffentiantion between an object that has a user interface and one that doesn’t.

  • Desktop: wrong, there is no difference between control sets of UI elements and non-UI elements. It’s not documented as far as I know, but it works without any problems. If you want to be on the safe side for the future, just subclass Control, or - if your class already has a superclass - wrap it in a Control.
  • Web: correct, but not really a problem, just subclass WebControl, or - if your class already has a superclass - wrap it in a WebControl.

[quote]WebObject: The super class of WebControl. Use this control when you want to add an instance of a class that has no user interface to your page. Examples of such classes are XojoScript, Serial, a custom class, etc.
[/quote]
Is it that my class doesn’t inherit from WebObject but rather ‘is a’ shell? perhaps my object should ‘have a’ shell?

Wrap it within a WebObject.