PDA

View Full Version : Simple slider question


sparaig
09-29-2006, 05:20 AM
Why does this not work?

It only prints test once, and not when I move the slider. If I change the -cc to -dc it STILL only prints test once.

This is the equivalent of hello world, I thought...


global proc testSliderCallback(string $testName)
{
print ("test\n");
}
global proc testSlider()
{
//----------------------------------



string $window = `window -title "intSliderGrp Example"`;
string $intSliderName;
string $cmd;
columnLayout;
$intSliderName = `intSliderGrp -label "Group 1" -field true `;

$cmd = (testSliderCallback($intSliderName));
intSliderGrp -edit -dragCommand $cmd $intSliderName ;

showWindow $window;


};
testSlider();

Mikademius
09-29-2006, 11:31 AM
can't you put the dragCommand at creation?

goleafsgo
09-29-2006, 01:24 PM
You need to change the line where you set the $cmd variable to this:
$cmd = "testSliderCallback(\"" + $intSliderName + "\")";

You were actually setting $cmd variable to the return of your test function...which was nothing so the string was empty. What you really want to do is set $cmd to the text of code that you want to execute when dragging the slider.

The line is slightly complicated because you should wrap the name of the slider in quotes, which means you need to use the backslash to get the quotes as part of your $cmd string.

sparaig
09-29-2006, 02:15 PM
can't you put the dragCommand at creation?

I tried that, but I was using the return string inside the creation string, so there was nothing there.

sparaig
09-29-2006, 02:47 PM
You need to change the line where you set the $cmd variable to this:
$cmd = "testSliderCallback(\"" + $intSliderName + "\")";

You were actually setting $cmd variable to the return of your test function...which was nothing so the string was empty. What you really want to do is set $cmd to the text of code that you want to execute when dragging the slider.

The line is slightly complicated because you should wrap the name of the slider in quotes, which means you need to use the backslash to get the quotes as part of your $cmd string.

Thanks very much. At first I couldn't get your solution to work because I cut and paste from the web page and apparently Safari embeds invisible characters. Typed in as shown and it worked. Thanks again.

CGTalk Moderation
09-29-2006, 02:47 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.