X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4850cc8b2e1037cd394806db4ddcf73868588a4c..3cfde7c049bddf6fd3b4c2e35a6b8ecdcdc1d74f:/src/osx/cocoa/spinbutt.mm diff --git a/src/osx/cocoa/spinbutt.mm b/src/osx/cocoa/spinbutt.mm index 980fc81dda..da57bbea78 100644 --- a/src/osx/cocoa/spinbutt.mm +++ b/src/osx/cocoa/spinbutt.mm @@ -18,12 +18,12 @@ @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 @@ -34,6 +34,7 @@ { [super initWithFrame:frame]; impl = NULL; + formerValue = 0; [self setTarget: self]; [self setAction: @selector(clickedAction:)]; return self; @@ -45,24 +46,38 @@ { 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