From: Richard K. <ric...@us...> - 2005-05-18 22:07:33
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16636 Modified Files: NSEvent.as NSControl.as NSCell.as ASEventMonitor.as NSButtonCell.as Log Message: got periodic events working! Index: ASEventMonitor.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/ASEventMonitor.as,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ASEventMonitor.as 6 May 2005 04:27:00 -0000 1.5 --- ASEventMonitor.as 18 May 2005 22:06:55 -0000 1.6 *************** *** 86,89 **** --- 86,97 ---- } + public function postPeriodicEvent() { + var modifierFlags = buildModifierFlags(); + var event = NSEvent.otherEventWithType(NSEvent.NSPeriodic, new NSPoint(_root._xmouse, _root._ymouse), + modifierFlags, (new Date()).getTime(), eval(m_mouseTrackingClip._dropTarget).view, + null /* context*/, 0 /*subType */, null /*data1 */, null /*data 2*/); + m_app.sendEvent(event); + } + private function mouseDown(targetPath:String) { var modifierFlags = buildModifierFlags(); Index: NSButtonCell.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSButtonCell.as,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** NSButtonCell.as 17 May 2005 16:26:29 -0000 1.15 --- NSButtonCell.as 18 May 2005 22:06:55 -0000 1.16 *************** *** 74,77 **** --- 74,80 ---- private var m_bcellTransparent:Boolean; private var m_backgroundColor:NSColor; + private var m_periodicInterval:Number; + private var m_periodicDelay:Number; + public function NSButtonCell() { *************** *** 186,189 **** --- 189,206 ---- } + // Setting the repeat interval + + /** + * Returns an object with delay and interval properties + */ + public function getPeriodicDelayInterval():Object { + return {delay:m_periodicDelay, interval:m_periodicInterval}; + } + + public function setPeriodicDelayInterval(delay:Number, interval:Number) { + m_periodicDelay = delay; + m_periodicInterval = interval; + } + // Setting the key equivalent Index: NSCell.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSCell.as,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NSCell.as 12 May 2005 19:38:26 -0000 1.9 --- NSCell.as 18 May 2005 22:06:55 -0000 1.10 *************** *** 99,102 **** --- 99,105 ---- private var m_controlTint:NSControlTint; private var m_controlView:NSView; + private var m_app:NSApplication; + private var m_periodicInterval:Number; + private var m_periodicDelay:Number; // An AS method cannot block, so a callback is needed for tracking mouse events *************** *** 129,132 **** --- 132,136 ---- m_controlTint = NSControlTint.NSDefaultControlTint; m_controlView = null; + m_app = NSApplication.sharedApplication(); } *************** *** 645,648 **** --- 649,654 ---- location: location, untilMouseUp: untilMouseUp, + action: action(), + target: target(), view: view, lastPoint: point, *************** *** 650,654 **** | NSEvent.NSMouseMovedMask | NSEvent.NSOtherMouseDraggedMask | NSEvent.NSRightMouseDraggedMask }; ! NSApplication.sharedApplication().callObjectSelectorWithNextEventMatchingMaskDequeue(this, "mouseTrackingCallback", m_trackingData.eventMask, true); } --- 656,665 ---- | NSEvent.NSMouseMovedMask | NSEvent.NSOtherMouseDraggedMask | NSEvent.NSRightMouseDraggedMask }; ! if(m_actionMask & NSEvent.NSPeriodicMask) { ! var times = getPeriodicDelayInterval(); ! NSEvent.startPeriodicEventsAfterDelayWithPeriod(times.delay, times.interval); ! m_trackingData.eventMask |= NSEvent.NSPeriodicMask; ! } ! m_app.callObjectSelectorWithNextEventMatchingMaskDequeue(this, "mouseTrackingCallback", m_trackingData.eventMask, true); } *************** *** 662,674 **** if (event.type == NSEvent.NSLeftMouseUp) { // mouse up? stopTrackingAtInViewMouseIsUp(m_trackingData.lastPoint, point, controlView(), true); ! //here ! m_trackingCallback[m_trackingCallbackSelector].call(m_trackingCallback, true); } else { // no mouse up if (continueTrackingAtInView(m_trackingData.lastPoint, point, controlView())) { m_trackingData.lastPoint = point; ! NSApplication.sharedApplication().callObjectSelectorWithNextEventMatchingMaskDequeue(this, "mouseTrackingCallback", m_trackingData.eventMask, true); } else { // don't continue...no mouse up stopTrackingAtInViewMouseIsUp(m_trackingData.lastPoint, point, controlView(), false); m_trackingCallback[m_trackingCallbackSelector].call(m_trackingCallback, false); } --- 673,694 ---- if (event.type == NSEvent.NSLeftMouseUp) { // mouse up? stopTrackingAtInViewMouseIsUp(m_trackingData.lastPoint, point, controlView(), true); ! setNextState(); ! m_trackingData.view.sendActionTo(m_trackingData.action, m_trackingData.target); ! if (m_actionMask & NSEvent.NSPeriodicMask) { ! NSEvent.stopPeriodicEvents(); ! } m_trackingCallback[m_trackingCallbackSelector].call(m_trackingCallback, true); } else { // no mouse up + if (event.type == NSEvent.NSPeriodic && m_actionMask & NSEvent.NSPeriodicMask) { //! Dragged too? + m_trackingData.view.sendActionTo(m_trackingData.action, m_trackingData.target); + } if (continueTrackingAtInView(m_trackingData.lastPoint, point, controlView())) { m_trackingData.lastPoint = point; ! m_app.callObjectSelectorWithNextEventMatchingMaskDequeue(this, "mouseTrackingCallback", m_trackingData.eventMask, true); } else { // don't continue...no mouse up stopTrackingAtInViewMouseIsUp(m_trackingData.lastPoint, point, controlView(), false); + if (m_actionMask & NSEvent.NSPeriodicMask) { + NSEvent.stopPeriodicEvents(); + } m_trackingCallback[m_trackingCallbackSelector].call(m_trackingCallback, false); } *************** *** 676,679 **** --- 696,706 ---- } } + + /** + * Returns an object with delay and interval properties + */ + public function getPeriodicDelayInterval():Object { + return {delay:.1, interval:.1}; + } public function startTrackingAtInView(startPoint:NSPoint, Index: NSControl.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSControl.as,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NSControl.as 17 May 2005 03:21:19 -0000 1.8 --- NSControl.as 18 May 2005 22:06:55 -0000 1.9 *************** *** 447,460 **** public function cellTrackingCallback(mouseUp:Boolean) { if(mouseUp) { - m_cell.setHighlighted(false); - m_cell.setNextState(); - setNeedsDisplay(true); m_cell.sendActionOn(m_trackingData.actionMask); - sendActionTo(action(), target()); m_cell.setTrackingCallbackSelector(null, null); } else { - m_cell.setHighlighted(false); - setNeedsDisplay(true); NSApplication.sharedApplication().callObjectSelectorWithNextEventMatchingMaskDequeue(this, "mouseTrackingCallback", m_trackingData.eventMask, true); } --- 447,456 ---- public function cellTrackingCallback(mouseUp:Boolean) { + m_cell.setHighlighted(false); + setNeedsDisplay(true); if(mouseUp) { m_cell.sendActionOn(m_trackingData.actionMask); m_cell.setTrackingCallbackSelector(null, null); } else { NSApplication.sharedApplication().callObjectSelectorWithNextEventMatchingMaskDequeue(this, "mouseTrackingCallback", m_trackingData.eventMask, true); } Index: NSEvent.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSEvent.as,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NSEvent.as 17 May 2005 03:21:19 -0000 1.4 --- NSEvent.as 18 May 2005 22:06:55 -0000 1.5 *************** *** 33,36 **** --- 33,39 ---- import org.actionstep.NSView; import org.actionstep.NSWindow; + import org.actionstep.NSTimer; + + import org.actionstep.ASEventMonitor; class org.actionstep.NSEvent extends NSObject { *************** *** 119,122 **** --- 122,126 ---- private static var g_instance:NSEvent = (new NSEvent()).init(); + private static var g_periodicTimer:NSTimer; // static constructors *************** *** 225,229 **** public static function otherEventWithType(type:Number, location:NSPoint, modifierFlags:Number, ! timestamp:Number, windowNumber:Number, context:Object, subtype:Number, data1:Object, data2:Object) { g_instance.type = type; --- 229,233 ---- public static function otherEventWithType(type:Number, location:NSPoint, modifierFlags:Number, ! timestamp:Number, view:NSView, context:Object, subtype:Number, data1:Object, data2:Object) { g_instance.type = type; *************** *** 231,237 **** g_instance.modifierFlags = modifierFlags; g_instance.timestamp = timestamp; ! g_instance.windowNumber = windowNumber; ! g_instance.window = NSWindow.instances()[windowNumber]; ! g_instance.view = null; g_instance.context = context; g_instance.subtype = subtype; --- 235,241 ---- g_instance.modifierFlags = modifierFlags; g_instance.timestamp = timestamp; ! g_instance.view = view; ! g_instance.window = view.window(); ! g_instance.windowNumber = g_instance.window.windowNumber(); g_instance.context = context; g_instance.subtype = subtype; *************** *** 257,261 **** return g_instance; } ! private function NSEvent() { } --- 261,282 ---- return g_instance; } ! ! public static function startPeriodicEventsAfterDelayWithPeriod(delay:Number, period:Number) { ! TRACE("Staring periodic events"); ! g_periodicTimer = new NSTimer(); ! var startDate = new Date(); ! startDate = startDate.setTime(startDate.getTime()+(delay*1000)); ! g_periodicTimer.initWithFireDateIntervalTargetSelectorUserInfoRepeats( ! startDate, period, ASEventMonitor.instance(), "postPeriodicEvent", {}, true); ! } ! ! public static function stopPeriodicEvents() { ! TRACE("Stopping periodic events"); ! if (g_periodicTimer != null) { ! g_periodicTimer.invalidate(); ! g_periodicTimer = null; ! } ! } ! private function NSEvent() { } |