NSSlider Targeting Several NSTextFields, Identifying an NSTextField
NSSlider Targeting Several NSTextFields, Identifying an NSTextField
- Subject: NSSlider Targeting Several NSTextFields, Identifying an NSTextField
- From: "Jordan Evans" <email@hidden>
- Date: Thu, 28 Sep 2006 16:01:52 -0700
I simply want to use a NSSlider to manipulate several NSTextFields.
But, each NSText field has a different range of values, so NSSlider's
attributes must change depending upon selected NSTextField. Specifics
below:
I want to create an NSDate String with the GMT format. Each
NSTextField represents one of these strings: (1)Year, (2)Month,
(3)Day, (4)Hour, (5)Minute, (6)Seconds and (7)GMT offset. After the
strings are created using one NSSlider and tabbing across seven
NSTextFields, I will append them into one string.
But to get this to work, I must know what NSTextField is selected.
When I know that, I can then set the NSSlider attributes, so the
NSSlider can increment in days, months, seconds, etc.
I have created an IBAction for the NSSlider. It calls this method
below. I have all the IBOutlets in Interface Builder connected with
the interface of my panellController class.
Here is where I am at. Any ideas why I can get the correct pre-set
value of the NSTextField, but I cannot get the tag although I have set
it? Without the tag, I cannot know the selected NSTextField, so then
off course the if statements won't be useful.
- (IBAction)scrollTextField:(id)sender
{
[gmt setTag:7];
[seconds setTag:6];
[minutes setTag:5];
[hours setTag:4];
[day setTag:3];
[month setTag:2];
[year setTag:1];
NSTextField *field = [[[self window] firstResponder] delegate];
NSLog(@"field: %i", [field intValue]);
int tag = [field tag];
NSLog(@"field tag: %i", tag);
// I'm only getting tag that are equal to zero, accept for the gmt.
It's the only one that gets a value, but only when it's correlating
cell is selected.
if ( tag == 7 )
{
NSLog(@"gmtOffset");
[sender setAltIncrementValue:100];
[sender setMaxValue:1200];
[sender setMinValue:-1100];
[sender setNumberOfTickMarks:24];
[self setgmt:[sender stringValue]];
}
if ( tag == 6 )
{
NSLog(@"seconds");
[sender setAltIncrementValue:1];
[sender setMaxValue:59];
[sender setMinValue:0];
[sender setNumberOfTickMarks:60];
[self setSeconds:[sender stringValue]];
}
if ( tag == 5 )
{
NSLog(@"minutes");
[sender setAltIncrementValue:1];
[sender setMaxValue:59];
[sender setMinValue:0];
[sender setNumberOfTickMarks:60];
[self setMinutes:[sender stringValue]];
}
if ( tag == 4 )
{
NSLog(@"hours");
[sender setAltIncrementValue:1];
[sender setMaxValue:23];
[sender setMinValue:0];
[sender setNumberOfTickMarks:24];
[self setHours:[sender stringValue]];
}
if ( tag == 3 )
{
NSLog(@"day");
[sender setAltIncrementValue:1];
[sender setMaxValue:31];
[sender setMinValue:1];
[sender setNumberOfTickMarks:31];
[self setDay:[sender stringValue]];
}
if ( tag == 2 )
{
NSLog(@"month");
[sender setAltIncrementValue:1];
[sender setMaxValue:12];
[sender setMinValue:1];
[sender setNumberOfTickMarks:12];
[self setMonth:[sender stringValue]];
}
if ( tag == 1 )
{
NSLog(@"year");
[sender setAltIncrementValue:1];
[sender setMaxValue:2009];
[sender setMinValue:2019];
[sender setNumberOfTickMarks:10];
[self setYear:[sender stringValue]];
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden