Problem linking floatField with floatSlider

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 10 October 2012   #1
Problem linking floatField with floatSlider

// Procedure that runs when the user changes the tolerance value
global proc float matchTolChange()
{
	global string $matchTolField;

	// Fetch field value
	global float $matchTol;
	$matchTol = `floatField -q -v $matchTolField`;
	floatField -e -v $matchTol $matchTolField;

	return $matchTol;
}

// Procedure for popping up the window for changing tolerance value
global proc changeTol()
{
	global float $matchTol;
	global string $matchTolField;
	global string $matchTolSlider;
	
	// In case the window is already open and hidden somewhere
	if (`window -exists matchTolWindow`) deleteUI matchTolWindow;
	
		// The window popup	
		window 
			-t "Adjust Match UVs -tolerance" 
			-mnb false 
			-mxb false 
			-resizeToFitChildren true
			matchTolWindow;

		columnLayout 
			-width 240 
			-height 130  
			-adjustableColumn true 
			-columnAlign "center" 
			-rowSpacing 6
			;
		
		text -label "";		
		text -label "text";
		text -label "text";		

		floatField 
			-minValue 0.001 
			-maxValue 0.1 
			-value $matchTol 
			-precision 3  
			-step 0.001 
			-width 50 
			$matchTolField;
			
		floatSlider 
			-minValue 0.001 
			-maxValue 0.1 
			-value $matchTol 
			-changeCommand "matchTolChange()"
			$matchTolSlider;
			
		button -label "Close" -command "matchTolChange()" -width 100;
		text -label "";		
				
	showWindow matchTolWindow;
}

Short summary of the code:
The first procedure does that actual change to the $matchTol variable and is supposed to update both the floatField and the floatSlider. Currently it only updates the floatField.

The second procedure pops up the window with the UI. It's supposed to run the first procedure - updating the $matchTol -variable - when the user clicks the close button or move the slider.

The problem I have is linking the floatSlider to the floatField and make sure both updates when the user touches one of them. What am I doing wrong here?
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 10 October 2012   #2
both floatField & floatSlider need to have a -cc so that when you click in them or drag them it will get the value from the field and edit the slider control and vice versa when you make a change.

ie

floatField -cc "float $x=`floatField -q -v myFloatField`;floatSlider -e -v $x myFloatSlider" myFloatField;
__________________
blah blah blah
 
Old 10 October 2012   #3
Thanks, that sorts the linking problem.
But CC only performs a command on change so the field wont update before the user lets go of the float slider. If you compare it with any other native Maya slider you will see that the associated fields always update when you drag the slider (click > drag > autoupdating) and not "just" when the user lets go of the slider. How can I achieve that effect?
(Mesh > Reduce for example has these kind of sliders)

EDIT: Nvm - I found out about floatSliderGrp
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.

Last edited by DeadlyNightshade : 10 October 2012 at 12:17 PM.
 
Old 10 October 2012   #4
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:28 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.