Control Array event handlers only affecting one control ?

I have code in the Action event handler for a bevelbutton set of 32 buttons

dim i as integer = me.index textarea1.text = textarea1.text + skypIconsArray(i)

This is my code which is supposed to update a textfield with a value from the array corresponding to the value that matches the value of the index of the control that is ‘actioned’

But the only control that is causing the event handler to fire is the last one in the set… with index 31
none of the other buttons in the set are working…

In addition… I have another app… where I have several control sets… and event handlers fire for all members of the control set… So confused…

You have an error in the first line of your code:

dim i as integer = me.index

It should be:

dim i as integer = index   // index is an argument of the event handler

i feel like a dunce. Thank you! :slight_smile:

eh… still doing same thing… crap

I noticed that… strangely bevelButton(31) has some like outline around it when the program is open… and none of the others do… this is the first time I’ve been frustrated like this… because I have no idea what it could be.

It means it has the focus.

[quote=118595:@chris ridgeway]But the only control that is causing the event handler to fire is the last one in the set… with index 31
none of the other buttons in the set are working…[/quote]
This is not possible since there is only one Action event for all instances of the control set. So if it works for the last one (index 31), it works for the others too. So maybe your skypIconsArray contains the same icon for index 0 to 31 ?

Put a break point in your action event and see whether index has the value you think it should.

[quote=118595:@chris ridgeway]But the only control that is causing the event handler to fire is the last one in the set… with index 31
none of the other buttons in the set are working…[/quote]

What is you code in Action ?

I had a similar problem a couple of days ago. I got it fixed by doing the following. I saved it as an XML project and then opened it in BBEdit to edit the XML file. I found the code for the menuitems having the problem and saw that for some reason the INDEX value was not set for some of the menuitems. I edited it to get all of the proper index values in place, saved it, and reloaded it in Xojo and all was fine. I won’t promise that this will fix your problem but it sure worked fine for me.

Let me mention that in that same program for some reason the index values were all out of whack so again I saved in XML, edited the file and changed the index values to what they were originally and that fixed that problem. Let me add that in my case this was a very old project that I was only working on to get it compiled for Cocoa. It was a very old .rbp file. Don’t know if that had anything to do with it but the editing of the XML fixed both problems.