I'll follow up on that tomorrow. Thanks,

Patrick

Hi,

I am using the following two methods for a scrolling number box which
is essentially a slider in the form of a NSTextField subclass.  I have
yet to implement this for my custom sliders but maybe this is a good
starting point for you?  When I first dabbled with custom sliders all
I did was override the mouseUp, mouseDown, mouseDragged methods etc
now my custom sliders are subclasses of NSControl rather than NSSlider.

-(void)mouseUp:(NSEvent*)theEvent
{
        if(drag) drag = NO;
}

-(void)mouseDragged:(NSEvent*)theEvent
{
        float val = [self floatValue];
        
        if(!drag) {
                // float start_x = [self convertPoint: [theEvent 
locationInWindow]
fromView: nil].x;
                start_y = [self convertPoint:[theEvent locationInWindow] 
fromView:
nil].y;
                prev_y = start_y;
                drag = YES;
        };
                
        // key modifier key flags
        unsigned int flags;
        flags = [theEvent modifierFlags];
        
        float next_y = [self convertPoint:[theEvent locationInWindow]
fromView: nil].y;
        float deltaY = (next_y - prev_y) / dragSize;
        prev_y = next_y;
        
        if(flags & NSAlternateKeyMask) deltaY *= fineGrain;
        val += range * deltaY;
        
        [self checkBounds:&val];
        [self setFloatValue:val];
        
        // continuously send the action
        [self sendAction:(SEL)[self action] to:(id)[self target]];
}

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to