Improve calculation for knob position when in On state

This commit is contained in:
Gregory John Casamento 2020-04-18 11:46:34 -04:00
parent da0f7ded36
commit d083bc061d
2 changed files with 38 additions and 1 deletions

View file

@ -902,7 +902,7 @@
}
else
{
rect = NSMakeRect(frame.origin.x + frame.size.width/2, frame.origin.y + 2,
rect = NSMakeRect(frame.origin.x + ((frame.size.width - w) - 4), frame.origin.y + 2,
w, frame.size.height - 4);
}

View file

@ -50,6 +50,8 @@
- (void) setAction: (SEL)action
{
NSString *s = NSStringFromSelector(action);
NSLog(@"Action %@",s);
_action = action;
}
@ -60,6 +62,7 @@
- (void) setTarget: (id)target
{
NSLog(@"Target %@", target);
_target = target;
}
@ -89,6 +92,40 @@
{
[self setState: NSControlStateValueOn];
}
if (_action)
{
[self sendAction: _action
to: _target];
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
if ((self = [super initWithCoder: aDecoder]) != nil)
{
if ([aDecoder allowsKeyedCoding])
{
if ([aDecoder containsValueForKey: @"NSAction"])
{
NSString *action = [aDecoder decodeObjectForKey: @"NSAction"];
if (action != nil)
{
[self setAction: NSSelectorFromString(action)];
}
}
if ([aDecoder containsValueForKey: @"NSTarget"])
{
id target = [aDecoder decodeObjectForKey: @"NSTarget"];
[self setTarget: target];
}
}
else
{
}
}
return self;
}
@end