Get all UI controls of as type withing a window / layout in MEL


#1

Hey folks

is there an easy way to, for instance, get all button items in a given layout / window?

I’ve written this recursive thingy, which actually doesn’t work, doesn’t return anything and I’m not smart enough to figure out why, so maybe someone would kindly help me, or there is likely a better way.

global proc string[] getAllUIofTypeinLayout(string $type, string $inputLayout){            
        
    string $lytchildren[] = `layout -q -ca $inputLayout`;
     
    string $tmpString[]; 
    
    for ($child in $lytchildren){
        if (`layout -q -ex $child`){
            $tmpString = getAllUIofTypeinLayout ($type, $child);
        }
        else if (`objectTypeUI -isType $type $child`){
        $tmpString[`size $tmpString`] = $child;
      }
    }
    
    string $allCntrlsOfType[] = stringArrayCatenate($tmpString, $allCntrlsOfType);

    return $allCntrlsOfType;
}

thanks