PDA

View Full Version : Button Text


nottoshabi
04-11-2009, 07:05 AM
How do you get the name of the obj I select with the button, to display in the text field?

string $window = `window`;
columnLayout;
textFieldButtonGrp -label "Selected"
-text "??"
-buttonLabel "Select"
-buttonCommand "ls-sl";
showWindow $window;

Buexe
04-11-2009, 07:40 AM
This should work, of course there are various ways to achieve this, this is just one:

string $window = `window`;
columnLayout;
global string $myCtrls[];
$myCtrls[0] = `textFieldButtonGrp -label "Selected"
-text "??"
-buttonLabel "Select"
-buttonCommand mySelectProc`;
showWindow $window;

global proc mySelectProc ()
{
global string $myCtrls[];
string $sel[] = `ls -sl`;
if ( size ( $sel ) == 1 )
textFieldButtonGrp -e -text $sel[0] $myCtrls[0];
else
warning "Please select one object.";
}

Etoia
04-11-2009, 07:53 AM
Here is another one (very similar to the one of Buexe).


string $window = `window`;
columnLayout;

textFieldButtonGrp -label "Selected"
-text "??"
-buttonLabel "Select"
-buttonCommand "CommandProc"
testTBG;

showWindow $window;


global proc CommandProc ()
{
string $sel[] = `ls -sl`;
$selObj = $sel[0];

textFieldButtonGrp -e -text $selObj testTBG;

}

The important part is :

textFieldButtonGrp -e -text $selObj testTBG;

With this command you can edit the text in the textFieldbuttonGroup with the name of the selected object.
Just put it after you have selected the object (the ls -sl command)

nottoshabi
04-14-2009, 09:27 AM
Dang this crap does not make any sense. Ok thanks I got that to work I had no idea I had to put that in a global proc.

Ok so now I'm trying to expand on this, I'm trying to get a text scroll list to display its selection. I'm using a button to store the selection and then display it in the scroll list.


//Multy constrain Window

//Create UI
string $window = `window -title "multyConstrainWin"
-iconName "multyConstrain"
-widthHeight 200 55`;

columnLayout -adjustableColumn true ;

textFieldButtonGrp
-label "Parent"
-text "??"
-buttonLabel "Select"
-buttonCommand "parentProc"
parentSelect;

separator -height 7 -style "double";

button
-align "center"
-w 25
-h 15
-label "Children"
-command "currentSelection" ;

separator -height 7 -style "double";

textScrollList -numberOfRows 8
-allowMultiSelection true
-append currentSelection;



setParent ..;
showWindow $window;


global proc currentSelection()
{
string $sel[] =`ls-sl`;
}


global proc parentProc()
{
string $sel[] = `ls-sl`;
string $parentSel = $sel[0];
textFieldButtonGrp -e -text $parentSel parentSelect;
}


I can not get the text scroll to display its selection after the button has been pushed? When the button is pushed then the contents of the array should be displayed in the text filed.
Does that have to be in a separate command?

And why is the button as large as the window when I set its h and w and told it to be centered?

Etoia
04-14-2009, 05:52 PM
It's the same thing for a textScrollList.

You make a TSL (don't forget to give it a name it's very important for this):


textScrollList -h 150
-w 100
testLoadSelTSL;


then a button :


button -l "Load Selection"
-c "Selection_Proc" //The button execute the proc who will populate the TSL
testLoadSelButton;



now here the proc to populate the TSL :



global proc Selection_Proc ()
{
textScrollList -e -removeAll testLoadSelTSL; //Remove all elements in the TSL.

string $sel[] = `ls -sl`;

//Put all each selected in the TSL :
for ($each in $sel)
{
textScrollList -e -append $each testLoadSelTSL; //This edit the TSL to append each selected element
}

}



What you are doing is making a TSL and a Button (place them in a window and a Layout).The TSL is blank in the begining (but you can fill it right when the UI is loaded if you want).
When you press the button you execute a proc who have :

- A command to clear the TSL (if previous elements are already here).
- You select the objects
- You make a condition that say for each element in the $sel[] variable, edit the TSL and append the element to the TSL.


For your other questions :


-Place the the comand for the TextField in the same proc. here an exemple for a script of mine where I take one object, put it in a Textfield and put is attributes in a TSL

global proc KBI_Single_TSL ()
{
textScrollList -e -removeAll selectAttrTSLSingle; //Remove all elements in the TSL.

string $sel[] = `ls -sl`;
$selObj = $sel[0]; //Get the first selected.

textField -e -text $selObj objectNameTFSingle; //Put the selected object in an invisible TF

string $objAttr[] = `listAttr -keyable $selObj`; //List all attributes of the first selected.

//Put all attributes in the TSL :
for ($eachAttr in $objAttr)
{
textScrollList -e -append $eachAttr selectAttrTSLSingle;
}

}


- For the size of the button.the problem come with the flag "adjustableColumn" set to true.This flag override the size parameter of the childrens (the button is a child).



I hope I've been clear to you.Let me know if you want a more detailed exemple.

nottoshabi
04-16-2009, 03:07 AM
Thanks yes that helped out. So I keep playing with it and I got this effect out of it its not exactlly what I"m looking for.

//Multy constrain Window

//Create UI
if (`window -ex multyConstrainWin` != true)
{
string $window = `window -title "multyConstrainWin"
-iconName "multyConstrain"
-widthHeight 200 55`;

columnLayout
-columnAttach "both" 8
-rowSpacing 10
-columnWidth 600;


separator -height 5 -w 600 -style "in";


textFieldButtonGrp
-label "Parent"
-text "??"
-buttonLabel "Select"
-buttonCommand "parentProc"
parentSelect;

separator -height 9 -w 600 -style "double";


button
-align "center"
-width 4
-label "Children"
-command "currentSelectionProc" ;


textScrollList -numberOfRows 8
-allowMultiSelection true
-width 200
-height 40
-append "??"
CurrentSelection;

setParent ..;
showWindow $window;
}
else
{
showWindow multyConstrainWin;
}


global proc currentSelectionProc()
{
string $sel[] =`ls-sl`;
for ($each in $sel)
{
textScrollList -append $each ;
}
}


global proc parentProc()
{
string $sel[] = `ls-sl`;
string $parentSel = $sel[0];
textFieldButtonGrp -e -text $parentSel parentSelect;
};


I dont know why it displays them like that, all with their own window and not in the default window? Also I tried putting a button at the bottom, but when I load the textScrol list it dysplayis it under the buttom. Even tho the button is the last thing that I want to display on the window.

CGTalk Moderation
04-16-2009, 03:07 AM
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.