Thanks Mark and Andre.

Mark's description of the solution is correct - but in my situation it's not a solution.

The sub-groups (B in my earlier example) are opaque - they have coloured, filled backdrops so that they can capture e.g. mouseMove messages, so they need to be opaque. Therefore, I can't simply re-layer so that the 'direct' graphics are behind (below) the groups.

The custom properties 'selector' idea is interesting - I'll need to mull it over some more.

I'm currently thinking of something like

function idOfChild pLongID, pShortName
  repeat for each line L in the childControlIDs of  pLongID
     if the short name of control ID L = pShortName then return the long id of control ID L
  end repeat
end idOfChild

unless someone sees a problem with that. (And of course I'll do that once and cache the values for continuing use).

Alex.

On 27/07/2020 15:40, Andre Garzia via use-livecode wrote:

Alex,

I think that Mark solution is the correct one but I couldn't resist telling
you some other idea, one that is only applicable if performance is not a
problem.

You can add custom properties to controls you want to find later and then
look for them by looping everyone in the card. A reusable short function
can be created with whatever letter you want, like "q", and code similar 
totrolIDs of
this:

function q selector, value
   repeat with x = 1 to the number of controls in this card
     if the selector of control x of this card is value then
       return the long id of control x of this card
     end if
   end repeat
end function

And then you can go:

put q("blue-rect", "true") into tLongID

You can even have something like "qq" that returns a list of long ids for
all the controls that match that query. Caching these results is the best
architecture, on preOpenCard you can find all the controls you'll need and
place them in script local arrays, then all the functions that need them
can peek into those arrays.

It is a bit convoluted but allows for some clever programming. Remembering
that "clever" is one of the trickster spirits of the software development
world.

Best
A

On Mon, 27 Jul 2020 at 01:33, Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:

I think my head is melting :-)

I have a group called 'A'.

Inside A, there is a rect called "R" and also a group called "B"

inside B there is a rect called "R"

How do I refer unambiguously to the first rectangle (i.e. A - R, not A -
B - R) ?

If I say
     grc "R" of grp "B" of grp A
then I unambiguously get A-B-R; but if I say simply
     grc "R" of grp "A"
then I *also* get A-B-R.

There must be a way to do this (and maybe if it wasn't nearly 2 in the
morning I would be able to figure it out).

Help! Please !

Alex.


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to