View Full Version : problem getting value of text field

11 November 2004, 05:05 PM
Hi guys!
I'm having some trouble with this UI im writing. It's just a test, so I can understand how they work.

I want to be able to produce a UI with field for name, float field for translation and a scale slider:

To get the values entered in the fields I query their values and store them in a global variable. Then I run the makeSphere procedure with the global variables for parameters.

//makeSphere procedure defs
global proc makeSphere( string $name, float $x, float $y, float $z, float $scale )
sphere -name $name;
move -r $x $y $z $name;
xform -scale $scale $scale $scale $name;

//user interface procedure
global proc makeSphereUI()
if( `window -exists sphereWin` )
deleteUI sphereWin;

window -title "Make sphere" sphereWin;
columnLayout columnLayout;
string $name_field = `textFieldGrp -label "Name:" name_field`;
string $move_field = `floatFieldGrp -label "Move" -numberOfFields 3 move_field`;
string $scale_field = `floatSliderGrp -label "Scale" -min 0.01 -max 10 -field true scale_field`;

global string $query_name_field;
global float $query_move_fieldX;
global float $query_move_fieldY;
global float $query_move_fieldZ;
global float $query_scale_field;

$query_name_field = `textFieldGrp -query -text $name_field`;
$query_move_fieldX = `floatFieldGrp -query -value1 $move_field`;
$query_move_fieldY = `floatFieldGrp -query -value2 $move_field`;
$query_move_fieldZ = `floatFieldGrp -query -value3 $move_field`;
$query_scale_field = `floatSliderGrp -query -value $scale_field`;

button -label "Do it" -command "makeSphere( $query_name_field, $query_move_fieldX, $query_move_fieldY, $query_move_fieldZ, $query_scale_field );";

showWindow sphereWin;

makeSphereUI; //build window

I get the following error; // Error: line 5: No object matches name: //

I hope someone can help me.
Cheers :)

11 November 2004, 05:29 PM
Try getting rid of the global variables and the passing in of the values to your makeSphere proc. Instead, just query for the values in the makeSphere proc.

So instead of having global var's which you want to hold the values, make the name of the UI elements global strings, or really specificly named in order to avoid naming conflicts, and then do the query and create your sphere.

Does that make sense? So your makeSphere would look sorta like:

global proc makeSphere()
global string $name_field;
global string $move_field;
global string $scale_field;

string $query_name_field;
float $query_move_fieldX;
float $query_move_fieldY;
float $query_move_fieldZ;
float $query_scale_field;

$query_name_field = `textFieldGrp -query -text $name_field`;
$query_move_fieldX = `floatFieldGrp -query -value1 $move_field`;
$query_move_fieldY = `floatFieldGrp -query -value2 $move_field`;
$query_move_fieldZ = `floatFieldGrp -query -value3 $move_field`;
$query_scale_field = `floatSliderGrp -query -value $scale_fi;

...then create the sphere using the values

11 November 2004, 06:18 PM
thanks dude :) ive got it fixed now :)
cheers :)

CGTalk Moderation
01 January 2006, 10:00 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.