View Full Version : dynamic UI - passing variables through -cc

05 May 2007, 07:23 PM

So, again, I am at a stand still and would appreciate any help. Here's the situation. I have a UI that generates controls based on an array... call it a dynamic UI. So if my array has 5 elements (which happen to be integers), 5 intField controls are created, and so on.

Certain validation needs to occur when a user changes the value of each of these integers. I use a call to -cc "validateData()". Each intField is given a unique name (made up like so : string $range = "entryPoint" + $x; where $x is a counter etc.). In the form it looks like so:

intField -v $someValue[$x] -cc "valiateData()" $range;

All of these works fine... But here's my problem. When -cc is invoked, I cannot tell which one of the intFields a change occurred to. I tried passing $x or the string that defines the filed's name as an argument that would reveal the affected element's identity, but $x is 0 (which makes sence after the creation of the UI), and $range gives me a "string not declared" error.

So here's my question:

How do I know which element in my UI was modified when the elements were dynamically created? (Without having to check each one, of course). Is there a "call back, parent, or id that I could query?

Thanks much.


05 May 2007, 05:00 AM
i think you expect a UI like the below, check it

global proc arTest()


if(`window -ex arTest`)deleteUI arTest;

window -t "arTest" -mbv 1 arTest;


menu -l "Check";

menuItem -l "rand" -c "myRand";

columnLayout arC1;


showWindow arTest;



global proc myRand()


int $arNumFields=rand(1,10);

if(`columnLayout -ex arC2`)deleteUI -lay arC2;

columnLayout -p arC1 arC2;

text -l ("The Random Value is "+$arNumFields) -w 150 -fn smallBoldLabelFont;

for($i=0; $i<$arNumFields; $i++)


intField -w 130 -cc ("myChecks(`intField -q -v "+"myInt"+$i+"`,"+$i+")") ("myInt"+$i);




global proc myChecks(int $arVal, int $arIVal)


print ("The Entered Field Name is: myInt"+$arIVal+"\n");

print ("The Value Entered is: "+$arVal);


hope it helps

05 May 2007, 04:59 PM
That is precisely what I needed to accomplish. I feel so stupid for asking that question. It must have been because it was a long day... I had forgotten to pass the explicit value of the variable in my function call. I realized that when I saw it on your code. I had done it before, so I knew it was possible, I feel rather stupid.

I was doing -cc "myFunction($x)" instead of -cc("myfunction("+$x+")")...

tsk tsk. I am sure your answer will most likely benefit more people than just me.

Thanks Arun.

CGTalk Moderation
05 May 2007, 04:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.