public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect) { using (PreventKeyboardDisplayIfSet()) { var wantsFocus = (_textBoxView?.RequestFocus(direction, previouslyFocusedRect)) .GetValueOrDefault(false); if (wantsFocus && FocusState == FocusState.Unfocused) { Focus(FocusState.Programmatic); } return(wantsFocus); } }
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, Rect previouslyFocusedRect) { Window window = ((Activity)Context).Window; if (gainFocus) { _startingMode = window.Attributes.SoftInputMode; window.SetSoftInputMode(SoftInput.AdjustPan); } else window.SetSoftInputMode(_startingMode); base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
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); }
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); // Delay padding update until after the keyboard has showed up otherwise updating the padding // stops the keyboard from showing up if (gainFocus) { Device.BeginInvokeOnMainThread(() => UpdatePadding()); } else { UpdatePadding(); } }
/// <summary> /// Called when the focus has changed on this view. /// </summary> /// <param name="gainFocus">If set to <c>true</c> gain focus.</param> /// <param name="direction">Direction.</param> /// <param name="previouslyFocusedRect">Previously focused rect.</param> protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); if (gainFocus) { SetBackgroundColor(Color.ParseColor(Crex.Application.Current.Config.Buttons.FocusedBackgroundColor)); SetTextColor(Color.ParseColor(Crex.Application.Current.Config.Buttons.FocusedTextColor)); } else { SetBackgroundColor(Color.ParseColor(Crex.Application.Current.Config.Buttons.UnfocusedBackgroundColor)); SetTextColor(Color.ParseColor(Crex.Application.Current.Config.Buttons.UnfocusedTextColor)); } }
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); if (this.Context.GetSystemService(Context.InputMethodService) is InputMethodManager imm) { if (gainFocus) { imm.ShowSoftInput(this, ShowFlags.Implicit); } else { imm.HideSoftInputFromWindow(this.WindowToken, HideSoftInputFlags.None); } } }
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, ARect previouslyFocusedRect) { Window window = Context.GetActivity().Window; if (gainFocus) { _startingMode = window.Attributes.SoftInputMode; window.SetSoftInputMode(SoftInput.AdjustPan); } else { window.SetSoftInputMode(_startingMode); } base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
public override AView FocusSearch(AView focused, [GeneratedEnum] FocusSearchDirection direction) { if (CheckCustomNextFocus(focused, direction)) { return(base.FocusSearch(focused, direction)); } var element = Element as ITabStopElement; int maxAttempts = 0; var tabIndexes = element?.GetTabIndexesOnParentPage(out maxAttempts); if (tabIndexes == null) { return(base.FocusSearch(focused, direction)); } // use OS default--there's no need for us to keep going if there's one or fewer tab indexes! if (tabIndexes.Count <= 1) { return(base.FocusSearch(focused, direction)); } int tabIndex = element.TabIndex; AView control = null; int attempt = 0; bool forwardDirection = !( (direction & FocusSearchDirection.Backward) != 0 || (direction & FocusSearchDirection.Left) != 0 || (direction & FocusSearchDirection.Up) != 0); do { element = element.FindNextElement(forwardDirection, tabIndexes, ref tabIndex); var renderer = (element as VisualElement)?.GetRenderer(); control = (renderer as ITabStop)?.TabStop; } while (!(control?.Focusable == true || ++attempt >= maxAttempts)); // when the user focuses on picker show a popup dialog if (control is IPopupTrigger popupElement) { popupElement.ShowPopupOnFocus = true; } return(control?.Focusable == true ? control : null); }
/// <summary> /// Perform filtering when focus gained /// </summary> /// <param name="gainFocus"></param> /// <param name="direction"></param> /// <param name="previouslyFocusedRect"></param> protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); if ((gainFocus == true) && (Adapter != null)) { // If there is no text make sure that the dropdown list is still displayed by forcing a text change if (Text.Length == 0) { Text = ""; } else { // If there is some text then re-show the dropdown list. // Don't do this if there is no text as the drop dopwn will not have been initialised ShowDropDown(); } } }
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, Android.Graphics.Rect previouslyFocusedRect) { if (gainFocus) { originalDuration = duration; input = DurationFieldInfo.Empty; Text = input.ToString(); moveCursorToEnd(); } else { ApplyDurationIfBeingEdited(); } isEditing = gainFocus; base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
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 override bool DispatchUnhandledMove(View focused, FocusSearchDirection direction) { if (direction == FocusSearchDirection.Left) { if (GetCurrentScreen() > 0) { SnapToScreen(GetCurrentScreen() - 1); return(true); } } else if (direction == FocusSearchDirection.Right) { if (GetCurrentScreen() < GetScreenCount() - 1) { SnapToScreen(GetCurrentScreen() + 1); return(true); } } return(base.DispatchUnhandledMove(focused, direction)); }
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, Android.Graphics.Rect previouslyFocusedRect) { isEditing = gainFocus; if (gainFocus) { originalDuration = duration; input = DurationFieldInfo.Empty; Text = input.ToString(); moveCursorToEnd(); } else { var actualDuration = input.IsEmpty ? originalDuration : input.ToTimeSpan(); Text = actualDuration.AsDurationString(); durationSubject.OnNext(actualDuration); Focusable = false; } base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
public override AView FocusSearch([GeneratedEnum] FocusSearchDirection direction) { var element = Content?.BindingContext as ITabStopElement; if (element == null) { return(base.FocusSearch(direction)); } int maxAttempts = 0; var tabIndexes = element?.GetTabIndexesOnParentPage(out maxAttempts); if (tabIndexes == null) { return(base.FocusSearch(direction)); } // use OS default--there's no need for us to keep going if there's one or fewer tab indexes! if (tabIndexes.Count <= 1) { return(base.FocusSearch(direction)); } int tabIndex = element.TabIndex; AView control = null; int attempt = 0; bool forwardDirection = !( (direction & FocusSearchDirection.Backward) != 0 || (direction & FocusSearchDirection.Left) != 0 || (direction & FocusSearchDirection.Up) != 0); do { element = element.FindNextElement(forwardDirection, tabIndexes, ref tabIndex); var renderer = (element as BindableObject).GetValue(Platform.RendererProperty); control = (renderer as ITabStop)?.TabStop; } while (!(control?.Focusable == true || ++attempt >= maxAttempts)); return(control?.Focusable == true ? control : null); }
/// <summary> /// Translates the USBCommand to the correct direction. /// And returns the id of the next element to focus. /// </summary> protected int NextItemToFocus(View element, USBCommand command) { FocusSearchDirection direction = Constants.CommandMap[command]; switch (direction) { case FocusSearchDirection.Up: return(element.NextFocusUpId); case FocusSearchDirection.Down: return(element.NextFocusDownId); case FocusSearchDirection.Left: return(element.NextFocusLeftId); case FocusSearchDirection.Right: return(element.NextFocusRightId); default: return(element.Id); } }
/** * <p>Handles scrolling in response to a "home/end" shortcut press. This * method will scroll the view to the top or bottom and give the focus * to the topmost/bottommost component in the new visible area. If no * component is a good candidate for focus, this scrollview reclaims the * focus.</p> * * @param direction the scroll direction: {@link android.view.View#FOCUS_UP} * to go the top of the view or * {@link android.view.View#FOCUS_DOWN} to go the bottom * @return true if the key event is consumed by this method, false otherwise */ public bool FullScroll(FocusSearchDirection direction, bool horizontal) { if (!horizontal) { bool down = direction == FocusSearchDirection.Down; int height = Height; mTempRect.Top = 0; mTempRect.Bottom = height; if (down) { int count = ChildCount; if (count > 0) { View view = GetChildAt(count - 1); mTempRect.Bottom = view.Bottom; mTempRect.Top = mTempRect.Bottom - height; } } return(ScrollAndFocus(direction, mTempRect.Top, mTempRect.Bottom, 0, 0, 0)); } else { bool right = direction == FocusSearchDirection.Down; int width = Width; mTempRect.Left = 0; mTempRect.Right = width; if (right) { int count = ChildCount; if (count > 0) { View view = GetChildAt(count - 1); mTempRect.Right = view.Bottom; mTempRect.Left = mTempRect.Right - width; } } return(ScrollAndFocus(0, 0, 0, direction, mTempRect.Top, mTempRect.Bottom)); } }
protected override void OnFocusChanged( bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); if (!gainFocus) { return; } if (this.Parent is ValuePickerRenderer parent2) { parent2.OnClick(); } else { if (!(this.Parent?.Parent?.Parent is ValuePickerRenderer parent3)) { return; } parent3.OnClick(); } }
public override bool DispatchUnhandledMove (View focused, FocusSearchDirection direction) { if (direction == FocusSearchDirection.Left) { if (GetCurrentScreen() > 0) { SnapToScreen(GetCurrentScreen() - 1); return true; } } else if (direction == FocusSearchDirection.Right) { if (GetCurrentScreen() < GetScreenCount() - 1) { SnapToScreen(GetCurrentScreen() + 1); return true; } } return base.DispatchUnhandledMove(focused, direction); }
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, ARect?previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); PickerManager.OnFocusChanged(gainFocus, this); }
public override void AddFocusables (IList<View> views, FocusSearchDirection direction, FocusablesFlags focusableMode) { View focusableSourceScreen = null; if (mCurrentScreen >= 0 && mCurrentScreen < GetScreenCount()) { focusableSourceScreen = GetScreenAt(mCurrentScreen); } if (direction == FocusSearchDirection.Left) { if (mCurrentScreen > 0) { focusableSourceScreen = GetScreenAt(mCurrentScreen - 1); } } else if (direction == FocusSearchDirection.Right) { if (mCurrentScreen < GetScreenCount() - 1) { focusableSourceScreen = GetScreenAt(mCurrentScreen + 1); } } if (focusableSourceScreen != null) { focusableSourceScreen.AddFocusables(views, direction, focusableMode); } }
public override bool RequestFocus(FocusSearchDirection direction, ARect previouslyFocusedRect) { return((this as IDescendantFocusToggler).RequestFocus(this, () => base.RequestFocus(direction, previouslyFocusedRect))); }
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); PickerManager.OnFocusChanged(gainFocus, this, (IPopupTrigger)Parent.Parent); }
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, Android.Graphics.Rect previouslyFocusedRect) { if (gainFocus) base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) { ShowClearIcon((!mClearIconDrawWhenFocused || gainFocus) && !TextUtils.IsEmpty(Text)); base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect) { return (this as IDescendantFocusToggler).RequestFocus(this, () => base.RequestFocus(direction, previouslyFocusedRect)); }
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, Android.Graphics.Rect previouslyFocusedRect) { base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); }
/** * <p>Scrolls the view to make the area defined by <code>top</code> and * <code>bottom</code> visible. This method attempts to give the focus * to a component visible in this area. If no component can be focused in * the new visible area, the focus is reclaimed by this scrollview.</p> * * @param direction the scroll direction: {@link android.view.View#FOCUS_UP} * to go upward * {@link android.view.View#FOCUS_DOWN} to downward * @param top the top offset of the new area to be made visible * @param bottom the bottom offset of the new area to be made visible * @return true if the key event is consumed by this method, false otherwise */ private bool ScrollAndFocus(FocusSearchDirection directionY, int top, int bottom, FocusSearchDirection directionX, int left, int right) { bool handled = true; int height = Height; int containerTop = ScrollY; int containerBottom = containerTop + height; bool up = directionY == FocusSearchDirection.Up; int width = Width; int containerLeft = ScrollX; int containerRight = containerLeft + width; bool leftwards = directionX == FocusSearchDirection.Up; View newFocused = FindFocusableViewInBounds(up, top, bottom, leftwards, left, right); if (newFocused == null) { newFocused = this; } if ((top >= containerTop && bottom <= containerBottom) || (left >= containerLeft && right <= containerRight)) { handled = false; } else { int deltaY = up ? (top - containerTop) : (bottom - containerBottom); int deltaX = leftwards ? (left - containerLeft) : (right - containerRight); DoScroll(deltaX, deltaY); } if (newFocused != FindFocus() && newFocused.RequestFocus(directionY)) { mTwoDScrollViewMovedFocus = true; mTwoDScrollViewMovedFocus = false; } return(handled); }
private void Scroll (FocusSearchDirection scrollDirection) { var scrollView = FindViewById<ScrollView> (Resource.Id.scroll); scrollView.Post (() => { scrollView.FullScroll (scrollDirection); }); }
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; }
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 override bool DispatchUnhandledMove(View focused, FocusSearchDirection direction) { return(mDragController.DispatchUnhandledMove(focused, direction)); }
/** * Handle scrolling in response to an up or down arrow click. * * @param direction The direction corresponding to the arrow key that was * pressed * @return True if we consumed the event, false otherwise */ public bool arrowScroll(FocusSearchDirection direction, bool horizontal) { View currentFocused = FindFocus(); if (currentFocused == this) { currentFocused = null; } View nextFocused = FocusFinder.Instance.FindNextFocus(this, currentFocused, direction); int maxJump = horizontal ? MaxScrollAmountHorizontal : MaxScrollAmountVertical; if (!horizontal) { if (nextFocused != null) { nextFocused.GetDrawingRect(mTempRect); OffsetDescendantRectToMyCoords(nextFocused, mTempRect); int scrollDelta = ComputeScrollDeltaToGetChildRectOnScreen(mTempRect); DoScroll(0, scrollDelta); nextFocused.RequestFocus(direction); } else { // no new focus int scrollDelta = maxJump; if (direction == FocusSearchDirection.Up && ScrollY < scrollDelta) { scrollDelta = ScrollY; } else if (direction == FocusSearchDirection.Down) { if (ChildCount > 0) { int daBottom = GetChildAt(0).Bottom; int screenBottom = ScrollY + Height; if (daBottom - screenBottom < maxJump) { scrollDelta = daBottom - screenBottom; } } } if (scrollDelta == 0) { return(false); } DoScroll(0, direction == FocusSearchDirection.Down ? scrollDelta : -scrollDelta); } } else { if (nextFocused != null) { nextFocused.GetDrawingRect(mTempRect); OffsetDescendantRectToMyCoords(nextFocused, mTempRect); int scrollDelta = ComputeScrollDeltaToGetChildRectOnScreen(mTempRect); DoScroll(scrollDelta, 0); nextFocused.RequestFocus(direction); } else { // no new focus int scrollDelta = maxJump; if (direction == FocusSearchDirection.Up && ScrollY < scrollDelta) { scrollDelta = ScrollY; } else if (direction == FocusSearchDirection.Down) { if (ChildCount > 0) { int daBottom = GetChildAt(0).Bottom; int screenBottom = ScrollY + Height; if (daBottom - screenBottom < maxJump) { scrollDelta = daBottom - screenBottom; } } } if (scrollDelta == 0) { return(false); } DoScroll(direction == FocusSearchDirection.Down ? scrollDelta : -scrollDelta, 0); } } return(true); }
public bool DispatchUnhandledMove(View focused, FocusSearchDirection direction) { return(mMoveTarget != null && mMoveTarget.DispatchUnhandledMove(focused, direction)); }