コード例 #1
0
        /// <summary>
        /// You can call this function yourself to have the scroll view perform
        /// scrolling from a key event, just as if the event had been dispatched to
        /// it by the view hierarchy.
        /// </summary>
        /// <param name="e"> The key event to execute. </param>
        /// <returns> Return true if the event was handled, else false. </returns>
        public bool ExecuteKeyEvent(KeyEvent e)
        {
            bool handled = false;

            if (e.Action == KeyEventActions.Down)
            {
                switch (e.KeyCode)
                {
                case Keycode.DpadLeft:
                    handled = ArrowScroll(FocusSearchDirection.Left);
                    break;

                case Keycode.DpadRight:
                    handled = ArrowScroll(FocusSearchDirection.Right);
                    break;

                case Keycode.Tab:
                    if (Build.VERSION.SdkInt >= (BuildVersionCodes)11)
                    {
                        // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
                        // before Android 3.0. Ignore the tab key on those devices.
                        if (KeyEventCompat.HasNoModifiers(e))
                        {
                            handled = ArrowScroll(FocusSearchDirection.Forward);
                        }
                        else if (KeyEventCompat.HasModifiers(e, (int)MetaKeyStates.ShiftOn))
                        {
                            handled = ArrowScroll(FocusSearchDirection.Backward);
                        }
                    }
                    break;
                }
            }
            return(handled);
        }
コード例 #2
0
        public bool ExecuteKeyEvent(KeyEvent ev)
        {
            var handled = false;
            if (ev.Action == KeyEventActions.Down)
            {
                switch (ev.KeyCode)
                {
                    case Keycode.DpadLeft:
                        handled = ArrowScroll(FocusSearchDirection.Left);
                        break;
                    case Keycode.DpadRight:
                        handled = ArrowScroll(FocusSearchDirection.Right);
                        break;
                    case Keycode.Tab:
                        if ((int)Build.VERSION.SdkInt >= 11)
                        {
                            if (KeyEventCompat.HasNoModifiers(ev))
                                handled = ArrowScroll(FocusSearchDirection.Forward);
#if __ANDROID_11__
                            else if (ev.IsMetaPressed)
                                handled = ArrowScroll(FocusSearchDirection.Backward);
#endif
                        }
                        break;
                }
            }
            return handled;
        }