public bool ArrowScroll(FocusSearchDirection direction) { var currentFocused = FindFocus(); var handled = false; var nextFocused = FocusFinder.Instance.FindNextFocus(this, currentFocused == this ? null : currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == FocusSearchDirection.Left) handled = nextFocused.RequestFocus(); else if (direction == FocusSearchDirection.Right) { if (currentFocused != null && nextFocused.Left <= currentFocused.Left) handled = PageRight(); else handled = nextFocused.RequestFocus(); } } else if (direction == FocusSearchDirection.Left || direction == FocusSearchDirection.Backward) handled = PageLeft(); else if (direction == FocusSearchDirection.Right || direction == FocusSearchDirection.Forward) handled = PageRight(); if (handled) PlaySoundEffect(SoundEffectConstants.GetContantForFocusDirection(direction)); return handled; }
public bool ArrowScroll(FocusSearchDirection direction) { View currentFocused = FindFocus(); if (currentFocused == this) { currentFocused = null; } bool handled = false; View nextFocused = FocusFinder.Instance.FindNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == FocusSearchDirection.Left) { handled = nextFocused.RequestFocus(); } else if (direction == FocusSearchDirection.Right) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.Left <= currentFocused.Left) { handled = PageRight(); } else { handled = nextFocused.RequestFocus(); } } } else if (direction == FocusSearchDirection.Left || direction == FocusSearchDirection.Backward) { // Trying to move left and nothing there; try to page. handled = PageLeft(); } else if (direction == FocusSearchDirection.Right || direction == FocusSearchDirection.Forward) { // Trying to move right and nothing there; try to page. handled = PageRight(); } if (handled) { PlaySoundEffect(SoundEffectConstants.GetContantForFocusDirection(direction)); } return(handled); }