View Full Version : UI that changes dynamically from user inputs
instruct9r 12-05-2006, 12:38 PM Is that possible... just want to know...
Lets say i have infField and a button, and below 2 textField's (not exactly 2 but for example)... What is the idea... The user type 5 in the intField and by pressing the button the UI updates with 5 textFields... Is that possible?? Can i make textFields with Loop??
When we have in mind that i will query from those textFields and i need to give them names that i'll be able to use later..
10x http://creaturetd.com/forums/images/smiles/icon_smile.gif
|
|
goleafsgo
12-05-2006, 01:31 PM
Yes it is possible. Here is something to get you started. This is by no means perfect code...only a starting point for you.
global proc testCallback(string $intField, string $parent)
{
int $val = `intField -q -value $intField`;
setParent $parent;
int $i;
for ($i=0; $i<$val; $i++)
{
textField;
}
}
{
window;
string $parent = `columnLayout`;
string $intField = `intField`;
button -command ("testCallback(\"" + $intField + "\", \"" + $parent + "\")");
showWindow;
}
brubin
12-05-2006, 02:04 PM
try this:
if you hit <enter> the number of textFields changes; if you hit <do it> the text of each textField gets printed to the scriptEditor output ;
global proc dynMItestWindow()
{
if(`window -ex "dynMItestWin"`) deleteUI "dynMItestWin" ;
if(`windowPref -exists "dynMItestWin"`) windowPref -remove "dynMItestWin" ;
string $win = `window -h 90 -w 185 "dynMItestWin"` ;
string $form = `formLayout dynMIfl` ;
string $col = `columnLayout -adj 1 dynMIcl` ;
string $intF = `intField -v 0 -cc "dynMIcommand" dynMIif` ;
setParent $form ;
string $but = `button -l "do it!" -c "dynMIreadTextfields" dynMIdoB` ;
formLayout -e -af $col "top" 5
-af $col "left" 5
-af $col "right" 5
-ac $col "bottom" 10 $but
-af $but "left" 5
-af $but "right" 5
-af $but "bottom" 5
$form ;
showWindow $win ;
}
global proc dynMIcommand()
{
int $val = `intField -q -v dynMIif` ;
int $i , $n ;
int $noc = `columnLayout -q -nch dynMIcl` ;
string $kids[] = `columnLayout -q -ca dynMIcl` ;
// first delete all textfields if already present
if($noc > 1)
{
for($i=0 ; $i < $noc ; $i++)
{
if($kids[$i] != "dynMIif")
deleteUI -control $kids[$i] ;
}
window -e -h 90 "dynMItestWin" ;
}
for($i = 0; $i < $val ; $i++ )
{
$n = $i + 1 ;
textField -p "dynMIcl" -tx ("I\'m text in textfield no. "+$n) ("dynMItf_"+$n) ;
window -e -h (`window -q -h dynMItestWin`+22) dynMItestWin ;
}
}
global proc dynMIreadTextfields()
{
int $val = `intField -q -v dynMIif` ;
int $i , $n ;
string $txt ;
print ("\n// ############################################################################# //\n") ;
for($i = 0; $i < $val ; $i++ )
{
$n = $i + 1 ;
$txt = `textField -q -tx ("dynMItf_"+$n)` ;
print ($txt + "\n") ;
}
print ("// ############################################################################# //\n\n") ;
}
dynMItestWindow ;
HIH
s.
instruct9r
12-05-2006, 04:15 PM
thankss.. :)
CGTalk Moderation
12-05-2006, 04:15 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.