Duplicate Control Names - Don't understand

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Duplicate Control Names - Don't understand

Post by Traxgeek » Fri Oct 24, 2014 2:46 pm

Further to the thread and its findings above, I have found one other VERY IMPORTANT caveat to playing with duplicate control names.

For me, dare I say it ... it's a bug... BUT... please bear with me, like I said, I'm none too good at explaining concisely...

Bernd above (et all) all have valid points BUT...

... should you have a control at card level (not within any additional group) called 'ControlA' and you have another (copy) 'ControlA' within a group 'GroupA' (on the same card), then,
it is (obviously) possible to select the grouped control with something like... 'ControlA of group 'GroupA' - no problems there...
HOWEVER
if you try to select 'ControlA' (just 'ControlA' !) then EITHER the control at card level (ungrouped) will be selected OR the control within the group will be selected - even though the group granularity has not been specified...
Furthermore, the same remains true for 'ControlA" of card "CardA' (i.e. trying to force LC to recognise that no additional group granularity is intended or required) ! In fact LC can select one OR the other...

For me this was VERY confusing...

Workarounds :
Place any (and all) Control(s), that is(are) to be duplicated within an additional group then it is ALWAYS possible to specify the required control by including the control's group container within the 'path' to the intended control (basic control granularity)
Playing further I found that LC doesn't arbitrarily select (rather unsurprisingly) a control from a list of similarly named controls; rather, it selects the LOWEST LAYER (highest control in the control hierarchy chart) numbered control should additional granularity (of group "...) not be specified... phew... therefore, if a grouped control with 'ControlA' ('ControlA' of group 'GroupA') is created BEFORE an ungrouped control then -1- it will have a lower layer number and -2- it will, therefore, be selected before all other similarly named controls even though the others are / are not contained within a group (assuming one uses the 'ControlA' or 'ControlA' of card "CardA' syntax)...
The way around this is to manually alter the level of ay card level control to be lower than any other grouped control...

I'm not sure if this makes any sense (it does, now, to me - may take a few reads...) and would explain why others advise one NOT to duplicate control names on a card...
For, me an ungrouped control should ALWAYS be higher up in the hierarchy chart than any grouped control with the same name - certainly this is the case with the other languages I've mentioned - I just went and tried !

Just my 2 cents worth ! Hope this adds some additional clarity.
Again, thanks to you all for your help, without which I would have just reverted to hugely long (and unnecessary) control names...
Thanks a million. Have a great weekend.

Regards,
TRAX
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Post Reply