From: Richard K. <ric...@us...> - 2005-07-16 22:23:52
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16999 Modified Files: NSApplication.as NSView.as NSWindow.as Log Message: getting Event loops working (allowing nextKeyView/previousKeyView) Index: NSView.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSView.as,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** NSView.as 15 Jul 2005 21:31:10 -0000 1.27 --- NSView.as 16 Jul 2005 22:23:41 -0000 1.28 *************** *** 83,86 **** --- 83,90 ---- private var m_needsDisplay:Boolean; + // key view loop + private var m_nextKeyView:NSView; + private var m_previousKeyView:NSView; + // MovieClip variables private var m_mcFrame:MovieClip; *************** *** 814,817 **** --- 818,873 ---- } + // Managing the key view loop + + public function canBecomeKeyView():Boolean { + return acceptsFirstResponder() && isHiddenOrHasHiddenAncestor(); + } + + public function needsPanelToBecomeKey():Boolean { + return false; + } + + public function setNextKeyView(view:NSView) { + if (view == null || view instanceof NSView) { + if (view == null) { + m_nextKeyView.m_previousKeyView = null; + m_nextKeyView = null; + } else { + m_nextKeyView = view; + view.m_previousKeyView = this; + } + } else { + throw new Error("NSInternalInconsistencyException"); + } + } + + public function nextKeyView():NSView { + return m_nextKeyView; + } + + public function nextValidKeyView():NSView { + var result:NSView = m_nextKeyView; + while (true) { + if (result == null || result == this || result.canBecomeKeyView()) { + return result; + } + result = result.m_nextKeyView; + } + } + + public function previousKeyView():NSView { + return m_previousKeyView; + } + + public function previousValidKeyView():NSView { + var result:NSView = m_previousKeyView; + while (true) { + if (result == null || result == this || result.canBecomeKeyView()) { + return result; + } + result = result.m_previousKeyView; + } + } + //****************************************************** //* Controlling Notifications Index: NSWindow.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSWindow.as,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** NSWindow.as 15 Jul 2005 19:57:57 -0000 1.22 --- NSWindow.as 16 Jul 2005 22:23:41 -0000 1.23 *************** *** 43,46 **** --- 43,47 ---- import org.actionstep.constants.NSWindowOrderingMode; + import org.actionstep.constants.NSSelectionDirection; class org.actionstep.NSWindow extends NSResponder { *************** *** 91,95 **** private var m_contentRect:NSRect; private var m_firstResponder:NSResponder; ! private var m_initialFirstResponder:NSResponder; private var m_rootView:ASRootWindowView; private var m_contentView:NSView; --- 92,96 ---- private var m_contentRect:NSRect; private var m_firstResponder:NSResponder; ! private var m_initialFirstResponder:NSView; private var m_rootView:ASRootWindowView; private var m_contentView:NSView; *************** *** 100,106 **** private var m_title:String; - //private var m_keyWin:Number; - //private var m_mainWin:Number; - private var m_isKey:Boolean; private var m_isMain:Boolean; --- 101,104 ---- *************** *** 109,112 **** --- 107,112 ---- private var m_level:Number; + + private var m_selectionDirection:NSSelectionDirection; public function NSWindow() { *************** *** 122,134 **** m_level = NSNormalWindowLevel; m_windowNumber = g_instances.length; ! //var x = m_windowNumber; ! //if(m_keyWin==null) { ! //m_keyWin = x; ! //m_app.setKeyWindow(this); ! //} ! //if(m_mainWin==null) { ! //m_mainWin = x; ! //m_app.setMainWindow(this); ! //} } --- 122,126 ---- m_level = NSNormalWindowLevel; m_windowNumber = g_instances.length; ! m_selectionDirection = NSSelectionDirection.NSDirectSelection; } *************** *** 472,486 **** } } ! ! public function initialFirstResponder():NSResponder { return m_initialFirstResponder; } ! public function setInitialFirstResponder(value:NSResponder) { ! if (value instanceof NSView) { ! m_initialFirstResponder = value; } } // Working with display characteristics --- 464,563 ---- } } ! ! // Keyboard interface control ! ! public function setInitialFirstResponder(view:NSView) { ! if (view instanceof NSView) { ! m_initialFirstResponder = view; ! } ! } ! ! public function initialFirstResponder():NSView { return m_initialFirstResponder; } ! public function selectKeyViewFollowingView(view:NSView) { ! var fView:NSView; ! if (view instanceof NSView) { ! fView = view.nextValidKeyView(); ! if (fView != null) { ! makeFirstResponder(fView); ! if (fView.respondsToSelector("selectText")) { ! m_selectionDirection = NSSelectionDirection.NSSelectingNext; ! Object(fView).selectText(this); ! m_selectionDirection = NSSelectionDirection.NSDirectSelection; ! } ! } } } + public function selectKeyViewPrecedingView(view:NSView) { + var pView:NSView; + if (view instanceof NSView) { + pView = view.previousValidKeyView(); + if (pView != null) { + makeFirstResponder(pView); + if (pView.respondsToSelector("selectText")) { + m_selectionDirection = NSSelectionDirection.NSSelectingPrevious; + Object(pView).selectText(this); + m_selectionDirection = NSSelectionDirection.NSDirectSelection; + } + } + } + } + + public function selectNextKeyView(sender:Object) { + var result:NSView = null; + if (m_firstResponder instanceof NSView) { + result = NSView(m_firstResponder).nextValidKeyView(); + } + if (result == null && m_initialFirstResponder != null) { + if (m_initialFirstResponder.acceptsFirstResponder()) { + result = m_initialFirstResponder; + } else { + result = m_initialFirstResponder.nextValidKeyView(); + } + } + if (result != null) { + makeFirstResponder(result); + if (result.respondsToSelector("selectText")) { + m_selectionDirection = NSSelectionDirection.NSSelectingNext; + Object(result).selectText(this); + m_selectionDirection = NSSelectionDirection.NSDirectSelection; + } + } + } + + public function selectPreviousKeyView(sender:Object) { + var result:NSView = null; + if (m_firstResponder instanceof NSView) { + result = NSView(m_firstResponder).previousValidKeyView(); + } + if (result == null && m_initialFirstResponder != null) { + if (m_initialFirstResponder.acceptsFirstResponder()) { + result = m_initialFirstResponder; + } else { + result = m_initialFirstResponder.previousValidKeyView(); + } + } + if (result != null) { + makeFirstResponder(result); + if (result.respondsToSelector("selectText")) { + m_selectionDirection = NSSelectionDirection.NSSelectingPrevious; + Object(result).selectText(this); + m_selectionDirection = NSSelectionDirection.NSDirectSelection; + } + } + } + + public function keyViewSelectionDirection():NSSelectionDirection { + return m_selectionDirection; + } + + /* + â selectPreviousKeyView: + â keyViewSelectionDirection + */ + // Working with display characteristics Index: NSApplication.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/NSApplication.as,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** NSApplication.as 15 Jul 2005 14:00:09 -0000 1.23 --- NSApplication.as 16 Jul 2005 22:23:40 -0000 1.24 *************** *** 447,450 **** --- 447,453 ---- } //end--sheets + + + // NSWindows notifications private function __windowWillClose(notification:NSNotification) { |