View Full Version : Very Quick Question About NSSlider
What is the function for reading the value from a NSSlider?
I've searched the forums for 'nsslider' and 'cocoa slider' as well as searching google for 'nsslider', 'nsslider get value', and 'cocoa slider' and have yet to find how. I've tried some methods from other things (like getFloatValue) only to find out that it doesn't work. If someone could just quick post it, I'd appreciate it.
skyhawk
2004.09.30, 07:58 PM
[mySlider intValue] or [mySlider floatValue]
i see. I was trying to use things like getFloatValue and getIntValue. Thanks.
I'm having some trouble. It's getting the values from the sliders, but when I move them the box doesn't change colors until I click on MyOpenGLView. Here's the code from the drawing (some OpenGL). I would've put it in the OpenGL forum but it seemed to be a slider problem as it does update later after I click the opengl window itself.
- (void)drawRect: (NSRect)aRect
{
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
{
glColor3ub([redAmount intValue],
[greenAmount intValue],
[blueAmount intValue]);
glVertex2f(50,50);
glVertex2f(250,50);
glVertex2f(250,250);
glVertex2f(50,250);
glEnd();
}
glFinish();
glFlush();
}
Taxxodium
2004.10.01, 12:55 AM
Next time check this (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/index.html) and this (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/index.html) before asking questions like this one.
And, just FYI, proper Objective-C coding convention asks that all accessors simply be the name of the variable. None of that silly "get" stuff.
Taxxodium
2004.10.01, 05:50 AM
None of that silly "get" stuff.
With the sole exception of NSImage's getRed:getGreen:getBlue etc :p
What about NSTextField? That uses a getFloatValue method as well.
With the sole exception of NSImage's getRed:getGreen:getBlue etc :p
Solely because those values have to be computed (eg. if the image is compressed) rather than just read out of a state variable.
What about NSTextField? That uses a getFloatValue method as well.NSTextField doesn't use -getFloatValue, AFAIK. Furthermore, I was only stating what the Objective-C coding convention is, not what Apple necessarily does. ;)
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.