< prev index next >

src/macosx/native/sun/awt/LWCToolkit.m

Print this page

        

@@ -37,10 +37,17 @@
 
 #import "sun_lwawt_macosx_LWCToolkit.h"
 
 #import "sizecalc.h"
 
+// SCROLL PHASE STATE
+#define SCROLL_PHASE_UNSUPPORTED 1
+#define SCROLL_PHASE_BEGAN 2
+#define SCROLL_PHASE_CONTINUED 3
+#define SCROLL_PHASE_CANCELLED 4
+#define SCROLL_PHASE_ENDED 5
+
 int gNumberOfButtons;
 jint* gButtonDownMasks;
 
 @implementation AWTToolkit
 

@@ -52,10 +59,27 @@
 
 + (void) eventCountPlusPlus{    
     eventCount++;
 }
 
++ (jint) scrollStateWithEvent: (NSEvent*) event {
+
+    if ([event type] != NSScrollWheel) {
+        return 0;
+    }
+
+    NSEventPhase phase = [event phase];
+    NSEventPhase momentumPhase = [event momentumPhase];
+
+    if (!phase && !momentumPhase) return SCROLL_PHASE_UNSUPPORTED;
+    switch (phase) {
+        case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN;
+        case NSEventPhaseCancelled: return SCROLL_PHASE_CANCELLED;
+        case NSEventPhaseEnded: return SCROLL_PHASE_ENDED;
+    }
+    return SCROLL_PHASE_CONTINUED;
+}
 @end
 
 
 @interface AWTRunLoopObject : NSObject {
     BOOL _shouldEndRunLoop;
< prev index next >