Пример #1
0
        protected override void KeyDownHandler(Event e)
        {
            if (e.Phase == EventPhase.Bubbling)
            {
                return;
            }

            if (!Enabled || null == DataGroup || e.DefaultPrevented)
            {
                return;
            }

            // Block input if space bar is being held down.
            if (null != _pressedIndex)
            {
                e.PreventDefault();
                return;
            }

            base.KeyDownHandler(e);

            KeyboardEvent ke = (KeyboardEvent)e;

            switch (ke.KeyCode)
            {
            case KeyCode.UpArrow:
            case KeyCode.LeftArrow:
            {
                AdjustCaretIndex(-1);
                e.PreventDefault();
                break;
            }

            case KeyCode.DownArrow:
            case KeyCode.RightArrow:
            {
                AdjustCaretIndex(+1);
                e.PreventDefault();
                break;
            }

            case KeyCode.Space:
            {
                IItemRenderer renderer = GetItemRenderer(CaretIndex) as IItemRenderer;
                if (null != renderer && ((!renderer.Selected && RequireSelection) || !RequireSelection))
                {
                    renderer.DispatchEvent(e);
                    _pressedIndex = CaretIndex;
                }
                break;
            }
            }
        }
Пример #2
0
        private void MouseWheelHandler(Event e)
        {
            IViewport vp = Viewport;

            if (e.DefaultPrevented || null == vp || !vp.Visible)
            {
                return;
            }

            //Debug.Log("HScrollBar MouseWheelHandler");

            MouseEvent me     = (MouseEvent)e;
            var        delta  = me.CurrentEvent.delta.y;
            int        nSteps = (int)Math.Abs(delta);

            nSteps = 1; // TEMP

            // Scroll event.delta "steps".
            //Debug.Log("delta: " + delta);
            NavigationUnit navigationUnit = (delta > 0) ? NavigationUnit.Right : NavigationUnit.Left;

            for (int hStep = 0; hStep < nSteps; hStep++)
            {
                float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit);
                //if (null != hspDelta)
                vp.HorizontalScrollPosition += hspDelta;
            }

            e.PreventDefault();
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool ProcessKeyDown(Event e)
        {
            KeyboardEvent ke = (KeyboardEvent)e;

            if (e.DefaultPrevented)
            {
                return(true);
            }

            if (ke.Control && ke.KeyCode == KeyCode.DownArrow)
            {
                OpenDropDownHelper(true); // Programmatically open
                e.PreventDefault();
            }
            else if (ke.Control && ke.KeyCode == KeyCode.UpArrow)
            {
                CloseDropDown(true);
                e.PreventDefault();
            }
            else if (ke.KeyCode == KeyCode.Return)
            {
                // Close the dropDown and eat the event if appropriate.
                if (IsOpen)
                {
                    CloseDropDown(true);
                    e.PreventDefault();
                }
            }
            else if (ke.KeyCode == KeyCode.Escape)
            {
                // Close the dropDown and eat the event if appropriate.
                if (IsOpen)
                {
                    CloseDropDown(false);
                    e.PreventDefault();
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
 private void SystemMouseWheelHandler(Event e)
 {
     if (!e.DefaultPrevented)
     {
         MouseEvent me       = (MouseEvent)e;
         float      newValue = NearestValidValue(Value + me.CurrentEvent.delta.y * StepSize, StepSize);
         SetValue(newValue);
         DispatchEvent(new Event(Event.CHANGE));
         e.PreventDefault();
     }
 }
Пример #5
0
        private void SkinMouseWheelHandler(Event e)
        {
            MouseEvent me = (MouseEvent)e;
            IViewport  vp = Viewport;

            if (e.DefaultPrevented || null == vp || !vp.Visible)
            {
                return;
            }

            var            delta  = me.CurrentEvent.delta.y;
            int            nSteps = (int)Math.Abs(delta);
            NavigationUnit navigationUnit;

            // Scroll event.delta "steps".  If the VSB is up, scroll vertically,
            // if -only- the HSB is up then scroll horizontally.

            if (null != VerticalScrollBar && VerticalScrollBar.Visible)
            {
                navigationUnit = (delta < 0) ? NavigationUnit.Down : NavigationUnit.Up;
                for (int vStep = 0; vStep < nSteps; vStep++)
                {
                    float?vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit);
                    //if (null != vspDelta)
                    vp.VerticalScrollPosition += (float)vspDelta;
                }
                e.PreventDefault();
            }
            else if (null != HorizontalScrollBar && HorizontalScrollBar.Visible)
            {
                navigationUnit = (delta < 0) ? NavigationUnit.Right : NavigationUnit.Left;
                for (int hStep = 0; hStep < nSteps; hStep++)
                {
                    float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit);
                    //if (null != hspDelta)
                    vp.HorizontalScrollPosition += hspDelta;
                }
                e.PreventDefault();
            }
        }
Пример #6
0
        private void MouseWheelHandler(Event e)
        {
            //Debug.Log("VScrollBar->MouseWheelHandler: " + e.Target);
            IViewport vp = Viewport;

            if (e.DefaultPrevented || null == vp || !vp.Visible)
            {
                return;
            }

            /* If the scrollbar is a part of the scroller, but is not visible, do not process mouse wheel
             * this way we are giving a chance for the horizontal scroll to work */
            if (!Visible)
            {
                return;
            }

            MouseEvent me = (MouseEvent)e;
            //Debug.Log(me.CurrentEvent.delta.y);
            var delta  = me.CurrentEvent.delta.y;
            int nSteps = (int)Math.Abs(delta);

            //Debug.Log("MouseWheelHandler. delta: " + delta);

            // Scroll event.delta "steps".
            nSteps = 1; // TEMP

            NavigationUnit navigationUnit = (delta > 0) ? NavigationUnit.Down : NavigationUnit.Up;

            for (int vStep = 0; vStep < nSteps; vStep++)
            {
                //Debug.Log("vStep: " + vStep);
                float vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit);
                //Debug.Log("  vspDelta: " + vspDelta);
                //if (null != vspDelta)
                vp.VerticalScrollPosition += vspDelta;
            }

            e.PreventDefault();
        }
Пример #7
0
        protected override void KeyUpHandler(Event e)
        {
            KeyboardEvent ke = (KeyboardEvent)e;

            switch (ke.KeyCode)
            {
            case KeyCode.DownArrow:
            case KeyCode.LeftArrow:
            case KeyCode.UpArrow:
            case KeyCode.RightArrow:
            {
                if (isKeyDown)
                {
                    // Dispatch "change" event only after a repeat occurs.
                    DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_END));
                    isKeyDown = false;
                }
                e.PreventDefault();
                break;
            }
            }
        }
Пример #8
0
        protected override void KeyDownHandler(Event e)
        {
            if (e.DefaultPrevented)
            {
                return;
            }

            KeyboardEvent ke = (KeyboardEvent)e;

            //if (animator && animator.isPlaying)
            //    stopAnimation();

            float prevValue = Value;
            float newValue;

            switch (ke.KeyCode)
            {
            case KeyCode.DownArrow:
            case KeyCode.LeftArrow:
            {
                newValue = NearestValidValue(PendingValue - StepSize, SnapInterval);

                if (prevValue != newValue)
                {
                    if (!isKeyDown)
                    {
                        DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START));
                        isKeyDown = true;
                    }
                    SetValue(newValue);
                    DispatchEvent(new Event(Event.CHANGE));
                }
                e.PreventDefault();
                break;
            }

            case KeyCode.UpArrow:
            case KeyCode.RightArrow:
            {
                newValue = NearestValidValue(PendingValue + StepSize, SnapInterval);

                if (prevValue != newValue)
                {
                    if (!isKeyDown)
                    {
                        DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START));
                        isKeyDown = true;
                    }
                    SetValue(newValue);
                    DispatchEvent(new Event(Event.CHANGE));
                }
                e.PreventDefault();
                break;
            }

            case KeyCode.Home:
            {
                Value = Minimum;
                if (Value != prevValue)
                {
                    DispatchEvent(new Event(Event.CHANGE));
                }
                e.PreventDefault();
                break;
            }

            case KeyCode.End:
            {
                Value = Maximum;
                if (Value != prevValue)
                {
                    DispatchEvent(new Event(Event.CHANGE));
                }
                e.PreventDefault();
                break;
            }
            }
        }
Пример #9
0
        protected override void KeyDownHandler(Event e)
        {
            if (e.Phase == EventPhase.Bubbling)
                return;
        
            if (!Enabled || null == DataGroup || e.DefaultPrevented)
                return;
        
            // Block input if space bar is being held down.
            if (null != _pressedIndex)
            {
                e.PreventDefault();
                return;
            }
        
            base.KeyDownHandler(e);

            KeyboardEvent ke = (KeyboardEvent) e;
            switch (ke.KeyCode)
            {
                case KeyCode.UpArrow:
                case KeyCode.LeftArrow:
                {
                    AdjustCaretIndex(-1);
                    e.PreventDefault();
                    break;
                }
                case KeyCode.DownArrow:
                case KeyCode.RightArrow:
                {
                    AdjustCaretIndex(+1);
                    e.PreventDefault();
                    break;
                }            
                case KeyCode.Space:
                {
                    IItemRenderer renderer = GetItemRenderer(CaretIndex) as IItemRenderer;
                    if (null != renderer && ((!renderer.Selected && RequireSelection) || !RequireSelection))
                    {
                        renderer.DispatchEvent(e);
                        _pressedIndex = CaretIndex;
                    }
                    break;
                }            
            }
        }
Пример #10
0
        private void MouseWheelHandler(Event e)
        {
            //Debug.Log("VScrollBar->MouseWheelHandler: " + e.Target);
            IViewport vp = Viewport;
            if (e.DefaultPrevented || null == vp || !vp.Visible)
                return;

            /* If the scrollbar is a part of the scroller, but is not visible, do not process mouse wheel
             * this way we are giving a chance for the horizontal scroll to work */
            if (!Visible)
                return;

            MouseEvent me = (MouseEvent) e;
            //Debug.Log(me.CurrentEvent.delta.y);
            var delta = me.CurrentEvent.delta.y;
            int nSteps = (int)Math.Abs(delta);
            //Debug.Log("MouseWheelHandler. delta: " + delta);

            // Scroll event.delta "steps".  
            nSteps = 1; // TEMP
            
            NavigationUnit navigationUnit = (delta > 0) ? NavigationUnit.Down : NavigationUnit.Up;
            for (int vStep = 0; vStep < nSteps; vStep++)
            {
                //Debug.Log("vStep: " + vStep);
                float vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit);
                //Debug.Log("  vspDelta: " + vspDelta);
                //if (null != vspDelta)
                vp.VerticalScrollPosition += vspDelta;
            }

            e.PreventDefault();
        }
Пример #11
0
        private void SkinMouseWheelHandler(Event e)
        {
            MouseEvent me = (MouseEvent) e;
            IViewport vp = Viewport;
            if (e.DefaultPrevented || null == vp || !vp.Visible)
                return;

            var delta = me.CurrentEvent.delta.y;
            int nSteps = (int) Math.Abs(delta);
            NavigationUnit navigationUnit;

            // Scroll event.delta "steps".  If the VSB is up, scroll vertically,
            // if -only- the HSB is up then scroll horizontally.
             
            if (null != VerticalScrollBar && VerticalScrollBar.Visible)
            {
                navigationUnit = (delta < 0) ? NavigationUnit.Down : NavigationUnit.Up;
                for (int vStep = 0; vStep < nSteps; vStep++)
                {
                    float? vspDelta = vp.GetVerticalScrollPositionDelta(navigationUnit);
                    //if (null != vspDelta)
                        vp.VerticalScrollPosition += (float)vspDelta;
                }
                e.PreventDefault();
            }
            else if (null != HorizontalScrollBar && HorizontalScrollBar.Visible)
            {
                navigationUnit = (delta < 0) ? NavigationUnit.Right : NavigationUnit.Left;
                for (int hStep = 0; hStep < nSteps; hStep++)
                {
                    float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit);
                    //if (null != hspDelta)
                        vp.HorizontalScrollPosition += hspDelta;
                }
                e.PreventDefault();
            }
        }
Пример #12
0
        protected override void KeyUpHandler(Event e)
        {
            KeyboardEvent ke = (KeyboardEvent) e;

            switch (ke.KeyCode)
            {
                case KeyCode.DownArrow:
                case KeyCode.LeftArrow:
                case KeyCode.UpArrow:
                case KeyCode.RightArrow:
                {
                    if (isKeyDown)
                    {
                        // Dispatch "change" event only after a repeat occurs.
                        DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_END));
                        isKeyDown = false;
                    }
                    e.PreventDefault();
                    break;
                }
            }
        }
Пример #13
0
        protected override void KeyDownHandler(Event e)
        {
            if (e.DefaultPrevented)
                return;

            KeyboardEvent ke = (KeyboardEvent) e;

            //if (animator && animator.isPlaying)
            //    stopAnimation();
            
            float prevValue = Value;
            float newValue;
            
            switch (ke.KeyCode)
            {
                case KeyCode.DownArrow:
                case KeyCode.LeftArrow:
                {
                    newValue = NearestValidValue(PendingValue - StepSize, SnapInterval);
                    
                    if (prevValue != newValue)
                    {
                        if (!isKeyDown)
                        {
                            DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START));
                            isKeyDown = true;
                        }
                        SetValue(newValue);
                        DispatchEvent(new Event(Event.CHANGE));
                    }
                    e.PreventDefault();
                    break;
                }

                case KeyCode.UpArrow:
                case KeyCode.RightArrow:
                {
                    newValue = NearestValidValue(PendingValue + StepSize, SnapInterval);
                    
                    if (prevValue != newValue)
                    {
                        if (!isKeyDown)
                        {
                            DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START));
                            isKeyDown = true;
                        }
                        SetValue(newValue);
                        DispatchEvent(new Event(Event.CHANGE));
                    }
                    e.PreventDefault();
                    break;
                }
                
                case KeyCode.Home:
                {
                    Value = Minimum;
                    if (Value != prevValue)
                        DispatchEvent(new Event(Event.CHANGE));
                    e.PreventDefault();
                    break;
                }

                case KeyCode.End:
                {
                    Value = Maximum;
                    if (Value != prevValue)
                        DispatchEvent(new Event(Event.CHANGE));
                    e.PreventDefault();
                    break;
                }
            }
        }
Пример #14
0
        protected override void KeyDownHandler(Event e)
        {
            if (!Enabled)
                return;

            KeyboardEvent ke = (KeyboardEvent) e;

            if (!DropDownController.ProcessKeyDown(e))
            {
                var navigationKey = ke.KeyCode;
                var navigationUnit = NavigationUnitUtil.GetNavigationUnit(navigationKey);
                           
                /*if (findKey(ke.charCode))
                {
                    event.preventDefault();
                    return;
                }*/
            
                if (!NavigationUnitUtil.IsNavigationUnit(navigationKey))
                    return;

                var proposedNewIndex = NO_SELECTION;
                int currentIndex;
                        
                if (IsDropDownOpen)
                {   
                    // Normalize the proposed index for getNavigationDestinationIndex
                    currentIndex = UserProposedSelectedIndex < NO_SELECTION ? NO_SELECTION : UserProposedSelectedIndex;
                    proposedNewIndex = Layout.GetNavigationDestinationIndex(currentIndex, navigationUnit, ArrowKeysWrapFocus);
                
                    if (proposedNewIndex != NO_SELECTION)
                    {
                        ChangeHighlightedSelection(proposedNewIndex);
                        e.PreventDefault();
                    }
                }
                else if (null != DataProvider)
                {
                    var maxIndex = DataProvider.Length - 1;
                
                    // Normalize the proposed index for getNavigationDestinationIndex
                    currentIndex = CaretIndex < NO_SELECTION ? NO_SELECTION : CaretIndex;

                    switch (navigationUnit)
                    {
                        case NavigationUnit.Up:
                        {
                            if (ArrowKeysWrapFocus && 
                                (currentIndex == 0 || 
                                 currentIndex == NO_SELECTION || 
                                 currentIndex == CUSTOM_SELECTED_ITEM))
                                proposedNewIndex = maxIndex;
                            else
                                proposedNewIndex = currentIndex - 1;  
                            e.PreventDefault();
                            break;
                        }                      
        
                        case NavigationUnit.Down:
                        {
                            if (ArrowKeysWrapFocus && 
                                (currentIndex == maxIndex || 
                                 currentIndex == NO_SELECTION || 
                                 currentIndex == CUSTOM_SELECTED_ITEM))
                                proposedNewIndex = 0;
                            else
                                proposedNewIndex = currentIndex + 1;  
                            e.PreventDefault();
                            break;
                        }
                        
                        case NavigationUnit.PageUp:
                        {
                            proposedNewIndex = currentIndex == NO_SELECTION ? 
                                NO_SELECTION : Math.Max(currentIndex - PAGE_SIZE, 0);
                            e.PreventDefault();
                            break;
                        }
                        
                        case NavigationUnit.PageDown:
                        {    
                            proposedNewIndex = currentIndex == NO_SELECTION ?
                                               PAGE_SIZE : (currentIndex + PAGE_SIZE);
                            e.PreventDefault();
                            break;
                        }
                       
                        case NavigationUnit.Home:
                        {
                            proposedNewIndex = 0;
                            e.PreventDefault();
                            break;
                        }

                        case NavigationUnit.End:
                        {
                            proposedNewIndex = maxIndex;  
                            e.PreventDefault();
                            break;
                        }  
                       
                    }
                
                    proposedNewIndex = Math.Min(proposedNewIndex, maxIndex);
                
                    if (proposedNewIndex >= 0)
                        SetSelectedIndex(proposedNewIndex, true);
                }
            }
            else
            {
                e.PreventDefault();
            }
        }
Пример #15
0
        protected override void KeyDownHandler(Event e)
        {
            //Debug.Log("KeyDownHandler: " + e.Target);

            base.KeyDownHandler(e);

            if (e.DefaultPrevented)
            {
                return;
            }

            //Debug.Log("KeyDownHandler: " + e.Target);

            float prevValue = Value;

            KeyboardEvent ke = (KeyboardEvent)e;

            switch (ke.KeyCode)
            {
            case KeyCode.DownArrow:
                //case Keyboard.LEFT:
            {
                ChangeValueByStep(false);
                e.PreventDefault();
                break;
            }

            case KeyCode.UpArrow:
                //case Keyboard.RIGHT:
            {
                ChangeValueByStep(true);
                e.PreventDefault();
                break;
            }

            case KeyCode.Home:
            {
                Value = Minimum;
                e.PreventDefault();
                break;
            }

            case KeyCode.End:
            {
                Value = Maximum;
                e.PreventDefault();
                break;
            }

            default:
            {
                base.KeyDownHandler(e);
                break;
            }
            }

            if (Value != prevValue)
            {
                DispatchEvent(new Event("change"));
            }
        }
Пример #16
0
 private void SystemMouseWheelHandler(Event e)
 {
     if (!e.DefaultPrevented)
     {
         MouseEvent me = (MouseEvent) e;
         float newValue = NearestValidValue(Value + me.CurrentEvent.delta.y * StepSize, StepSize);
         SetValue(newValue);
         DispatchEvent(new Event(Event.CHANGE));
         e.PreventDefault();
     }
 }
Пример #17
0
        protected override void KeyDownHandler(Event e)
        {
            //Debug.Log("KeyDownHandler: " + e.Target);

            base.KeyDownHandler(e);

            if (e.DefaultPrevented)
                return;

            //Debug.Log("KeyDownHandler: " + e.Target);
                    
            float prevValue = Value;

            KeyboardEvent ke = (KeyboardEvent) e;
            switch (ke.KeyCode)
            {
                case KeyCode.DownArrow:
                //case Keyboard.LEFT:
                {
                    ChangeValueByStep(false);
                    e.PreventDefault();
                    break;
                }

                case KeyCode.UpArrow:
                //case Keyboard.RIGHT:
                {
                    ChangeValueByStep(true);
                    e.PreventDefault();
                    break;
                }

                case KeyCode.Home:
                {
                    Value = Minimum;
                    e.PreventDefault();
                    break;
                }

                case KeyCode.End:
                {
                    Value = Maximum;
                    e.PreventDefault();
                    break;
                }
                
                default:
                {
                    base.KeyDownHandler(e);
                    break;
                }
            }

            if (Value != prevValue)
                DispatchEvent(new Event("change"));
        }
Пример #18
0
// ReSharper disable MemberCanBePrivate.Global
        protected void AdjustSelectionAndCaretUponNavigation(Event e)
// ReSharper restore MemberCanBePrivate.Global
        {
            //Debug.Log("AdjustSelectionAndCaretUponNavigation");

            KeyboardEvent ke = (KeyboardEvent) e;

            // Some unrecognized key stroke was entered, return. 
            if (!NavigationUnitUtil.IsNavigationUnit(ke.KeyCode))
                return;

            NavigationUnit navigationUnit = NavigationUnitUtil.GetNavigationUnit(ke.KeyCode);
            //Debug.Log("navigationUnit:" + navigationUnit);
            //Debug.Log("CaretIndex:" + CaretIndex);
                
            var proposedNewIndex = Layout.GetNavigationDestinationIndex(CaretIndex, navigationUnit, ArrowKeysWrapFocus);

            //Debug.Log("proposedNewIndex:" + proposedNewIndex);
            
            // Note that the KeyboardEvent is canceled even if the current selected or in focus index
            // doesn't change because we don't want another component to start handling these
            // events when the index reaches a limit.
            if (proposedNewIndex == -1)
                return;
                
            e.PreventDefault(); 
            
            // Contiguous multi-selection action. Create the new selection
            // interval.   
            if (_allowMultipleSelection && ke.Shift && null != SelectedIndices)
            {
                var startIndex = GetLastSelectedIndex(); 
                var newInterval = new List<int>();  
                int i; 
                if (startIndex <= proposedNewIndex)
                {
                    for (i = startIndex; i <= proposedNewIndex; i++)
                    {
                        newInterval.Insert(0, i); 
                    }
                }
                else 
                {
                    for (i = startIndex; i >= proposedNewIndex; i--)
                    {
                        newInterval.Insert(0, i); 
                    }
                }
                SetSelectedIndices(newInterval, true);
                EnsureIndexIsVisible(proposedNewIndex); 
            }
            // Entering the caret state with the Ctrl key down 
            else if (ke.Control)
            {
                var oldCaretIndex = CaretIndex;
                SetCurrentCaretIndex(proposedNewIndex);
                var ice = new IndexChangeEvent(IndexChangeEvent.CARET_CHANGE)
                              {
                                  OldIndex = oldCaretIndex,
                                  NewIndex = CaretIndex
                              };
                DispatchEvent(ice);    
                EnsureIndexIsVisible(proposedNewIndex); 
            }
            // Its just a new selection action, select the new index.
            else
            {
                SetSelectedIndex(proposedNewIndex, true);
                EnsureIndexIsVisible(proposedNewIndex);
            }
        }
Пример #19
0
        protected override void KeyDownHandler(Event e)
        {
            base.KeyDownHandler(e);

            //Debug.Log("Key down: " + e);
            KeyboardEvent ke = (KeyboardEvent) e;

            if (null == DataProvider || null == Layout || e.DefaultPrevented)
                return;

            // In lue of a formal item editor architecture (pending), we will
            // defer all keyboard events to the target if the target happens to 
            // be an editable input control.
            //if (isEditableTarget(event.target))
            //    return;
            
            // 1. Was the space bar hit? 
            // Hitting the space bar means the current caret item, 
            // that is the item currently in focus, is being 
            // selected. 
            if (ke.KeyCode == KeyCode.Space)
            {
                SetSelectedIndex(CaretIndex, true); 
                e.PreventDefault();
                return; 
            }

            // 2. Or was an alphanumeric key hit? 
            // Hitting an alphanumeric key causes List's
            // findKey method to run to find a matching 
            // item in the dataProvider whose first char 
            // matches the keystroke. 
            //if (findKey(event.charCode))
            //{
            //    event.preventDefault();
            //    return;
            //}
                
            // 3. Was a navigation key hit (like an arrow key,
            // or Shift+arrow key)?  
            // Delegate to the layout to interpret the navigation
            // key and adjust the selection and caret item based
            // on the combination of keystrokes encountered.      
            AdjustSelectionAndCaretUponNavigation(e); 
        }
Пример #20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool ProcessKeyDown(Event e)
        {
            KeyboardEvent ke = (KeyboardEvent) e;

            if (e.DefaultPrevented)
                return true;
        
            if (ke.Control && ke.KeyCode == KeyCode.DownArrow)
            {
                OpenDropDownHelper(true); // Programmatically open
                e.PreventDefault();
            }
            else if (ke.Control && ke.KeyCode == KeyCode.UpArrow)
            {
                CloseDropDown(true);
                e.PreventDefault();
            }    
            else if (ke.KeyCode == KeyCode.Return)
            {
                // Close the dropDown and eat the event if appropriate.
                if (IsOpen)
                {
                    CloseDropDown(true);
                    e.PreventDefault();
                }
            }
            else if (ke.KeyCode == KeyCode.Escape)
            {
                // Close the dropDown and eat the event if appropriate.
                if (IsOpen)
                {
                    CloseDropDown(false);
                    e.PreventDefault();
                }
            }
            else
            {
                return false;
            }   
            
            return true;        
        }
Пример #21
0
        private void MouseWheelHandler(Event e)
        {
            IViewport vp = Viewport;
            if (e.DefaultPrevented || null == vp || !vp.Visible)
                return;

            //Debug.Log("HScrollBar MouseWheelHandler");
            
            MouseEvent me = (MouseEvent)e;
            var delta = me.CurrentEvent.delta.y;
            int nSteps = (int)Math.Abs(delta);

            nSteps = 1; // TEMP

            // Scroll event.delta "steps".  
            //Debug.Log("delta: " + delta);
            NavigationUnit navigationUnit = (delta > 0) ? NavigationUnit.Right : NavigationUnit.Left;
            for (int hStep = 0; hStep < nSteps; hStep++)
            {
                float hspDelta = vp.GetHorizontalScrollPositionDelta(navigationUnit);
                //if (null != hspDelta)
                vp.HorizontalScrollPosition += hspDelta;
            }

            e.PreventDefault();
        }