@interface wxNSStepper : NSStepper
{
- wxWidgetCocoaImpl* impl;
+ WXCOCOAIMPL_COMMON_MEMBERS
+ int formerValue;
}
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
-- (wxWidgetCocoaImpl*) implementation;
-- (BOOL) isFlipped;
+WXCOCOAIMPL_COMMON_INTERFACE
+
- (void) clickedAction: (id) sender;
@end
{
[super initWithFrame:frame];
impl = NULL;
+ formerValue = 0;
[self setTarget: self];
[self setAction: @selector(clickedAction:)];
return self;
{
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
if ( wxpeer )
- wxpeer->HandleClicked(0);
+ {
+ // because wx expects to be able to veto
+ // a change we must revert the value change
+ // and expose it
+ int currentValue = [self intValue];
+ [self setIntValue:formerValue];
+ int inc = currentValue-formerValue;
+
+ // adjust for wrap arounds
+ if ( inc > 1 )
+ inc = -1;
+ else if (inc < -1 )
+ inc = 1;
+
+ if ( inc == 1 )
+ wxpeer->TriggerScrollEvent(wxEVT_SCROLL_LINEUP);
+ else if ( inc == -1 )
+ wxpeer->TriggerScrollEvent(wxEVT_SCROLL_LINEDOWN);
+
+ formerValue = [self intValue];
+ }
}
}
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
-{
- impl = theImplementation;
-}
-
-- (wxWidgetCocoaImpl*) implementation
+-(void)mouseDown:(NSEvent *)event
{
- return impl;
+ formerValue = [self intValue];
+ if ( !impl->DoHandleMouseEvent(event) )
+ [super mouseDown:event];
}
-- (BOOL) isFlipped
-{
- return YES;
-}
+WXCOCOAIMPL_COMMON_IMPLEMENTATION_NO_MOUSEDOWN
@end