# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1299032973 0 # Node ID d2d7d1802af4b44cf7fe64c3d736f92fc4f2f924 # Parent 0ec8edbb82cf7cc7e48bf5aa4cc5e95ed17e942a Implemented a rather hacky fix for the spinbutton issues. The stepper control is really poorly designed. The better fix would be to use a shared property but I can't figure out how to do that programmatically. So for the time being using this hacky method that actually works. diff -r 0ec8edbb82cf -r d2d7d1802af4 mac/dw.m --- a/mac/dw.m Tue Mar 01 14:56:48 2011 +0000 +++ b/mac/dw.m Wed Mar 02 02:29:33 2011 +0000 @@ -798,17 +798,48 @@ -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } @end +/* Subclass for a stepper component of the spinbutton type */ +/* This is a bad way of doing this... but I can't get the other methods to work */ +@interface DWStepper : NSStepper +{ + id textfield; +} +-(void)setTextfield:(id)input; +-(id)textfield; +-(void)mouseDown:(NSEvent *)event; +-(void)mouseUp:(NSEvent *)event; +@end + +@implementation DWStepper +-(void)setTextfield:(id)input { textfield = input; } +-(id)textfield { return textfield; } +-(void)mouseDown:(NSEvent *)event +{ + [super mouseDown:event]; + if([[NSApp currentEvent] type] == NSLeftMouseUp) + { + [textfield takeIntValueFrom:self]; + } +} +-(void)mouseUp:(NSEvent *)event +{ + [textfield takeIntValueFrom:self]; +} +@end + /* Subclass for a Spinbutton type */ -@interface DWSpinButton : NSView{ +@interface DWSpinButton : NSView +{ void *userdata; NSTextField *textfield; - NSStepper *stepper; + DWStepper *stepper; } -(id)init; -(void *)userdata; -(void)setUserdata:(void *)input; -(NSTextField *)textfield; -(NSStepper *)stepper; +-(void)controlTextDidChange:(NSNotification *)aNotification; @end @implementation DWSpinButton @@ -816,14 +847,15 @@ { self = [super init]; - if (self) + if(self) { textfield = [[NSTextField alloc] init]; [self addSubview:textfield]; - stepper = [[NSStepper alloc] init]; + stepper = [[DWStepper alloc] init]; [self addSubview:stepper]; + [stepper setTextfield:textfield]; [textfield takeIntValueFrom:stepper]; - [stepper takeIntValueFrom:textfield]; + [textfield setDelegate:self]; } return self; } @@ -831,6 +863,10 @@ -(void)setUserdata:(void *)input { userdata = input; } -(NSTextField *)textfield { return textfield; } -(NSStepper *)stepper { return stepper; } +-(void)controlTextDidChange:(NSNotification *)aNotification +{ + [stepper takeIntValueFrom:textfield]; +} -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } @end @@ -2062,7 +2098,9 @@ { DWSpinButton *spinbutton = handle; NSStepper *stepper = [spinbutton stepper]; + NSTextField *textfield = [spinbutton textfield]; [stepper setIntValue:(int)position]; + [textfield takeIntValueFrom:stepper]; } /*