private void DisableKeyboard(bool afterSelection) { var inputMethodManager = _context.GetSystemService(Context.InputMethodService) as InputMethodManager; inputMethodManager?.HideSoftInputFromWindow(ApplicationWindowToken, 0); KeyboardChanged?.Invoke(this, new SearchBoxKeyBoardEventArgs(afterSelection, SearchBoxKeyBoardEventArgs.KeyboardStatus.Closed)); }
private void EnableKeyboard() { var inputMethodManager = _context.GetSystemService(Context.InputMethodService) as InputMethodManager; inputMethodManager?.ToggleSoftInputFromWindow(ApplicationWindowToken, ShowSoftInputFlags.Explicit, 0); KeyboardChanged?.Invoke(this, new SearchBoxKeyBoardEventArgs(false, SearchBoxKeyBoardEventArgs.KeyboardStatus.Opened)); }
protected override void DoWork() { var k = _dev as Keyboard; k.Poll(); try { k.GetCurrentState(ref _devstate); } catch (NullReferenceException) { _devstate = k.GetCurrentState(); } KeyboardChanged?.Invoke(this, _devstate); }
/// <summary> /// Check for any change on the keyboard and perform the right actions. /// </summary> private static void CheckForKeyboardChange() { if (AnyKeyPressed()) { // KeyboardChanged event: Check if any key was pressed. KeyboardChanged?.Invoke(null, currentKeyboardState); // KeyPress event: List <Keys> pressedKeys = currentKeyboardState.GetPressedKeys().ToList(); KeyPressed?.Invoke(null, new KeyEventArgs( pressedKeys[0], currentKeyboardState.CapsLock, pressedKeys.Contains(Keys.LeftShift) || pressedKeys.Contains(Keys.RightShift), pressedKeys.Contains(Keys.LeftControl) || pressedKeys.Contains(Keys.RightControl), pressedKeys.Contains(Keys.LeftAlt) || pressedKeys.Contains(Keys.RightAlt))); } }
internal static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) { KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); }
private void MeasureLayout(PopupWindow sender) { var osVersion = Android.OS.Build.VERSION.SdkInt; if (osVersion >= Android.OS.BuildVersionCodes.R) { // Use newer API on 30 and above var windowMetrics = _activity.WindowManager.CurrentWindowMetrics; var imeInsets = windowMetrics.WindowInsets.GetInsets(WindowInsets.Type.Ime()); var windowBottom = windowMetrics.Bounds.Bottom; var keyboardHeight = windowBottom - imeInsets.Bottom; var keyboardRect = keyboardHeight > 0 ? new Rect(0, keyboardHeight, windowMetrics.Bounds.Right, windowBottom) : new Rect(); KeyboardChanged?.Invoke(keyboardRect); } else { #pragma warning disable 618 // We can obtain the size of keyboard by comparing the layout of two popup windows // where one (AdjustResize) resizes to keyboard and one(AdjustNothing) that doesn't: // [size] realMetrics : screen // [size] metrics : screen - dead zones // [rect] displayRect : screen - (bottom: nav_bar) // [rect] adjustNothingFrame : screen - (top: status_bar) - (bottom: nav_bar) // [rect] adjustResizeFrame : screen - (top: status_bar) - (bottom: keyboard + nav_bar) var realMetrics = Get <DisplayMetrics>(_activity.WindowManager.DefaultDisplay.GetRealMetrics); var metrics = Get <DisplayMetrics>(_activity.WindowManager.DefaultDisplay.GetMetrics); var displayRect = Get <Rect>(_activity.WindowManager.DefaultDisplay.GetRectSize); var adjustNothingFrame = Get <Rect>(_adjustNothingLayoutProvider.ContentView.GetWindowVisibleDisplayFrame); var adjustResizeFrame = Get <Rect>(_adjustResizeLayoutProvider.ContentView.GetWindowVisibleDisplayFrame); #pragma warning restore 618 var orientation = DisplayInformation.GetForCurrentView().CurrentOrientation; var keyboardRect = new Rect(0, adjustResizeFrame.Bottom, realMetrics.WidthPixels, adjustNothingFrame.Bottom); switch (orientation) { case DisplayOrientations.Landscape: NavigationBarRect = new Rect(0, 0, metrics.WidthPixels - displayRect.Width(), metrics.HeightPixels); break; case DisplayOrientations.LandscapeFlipped: NavigationBarRect = new Rect(adjustNothingFrame.Width(), 0, metrics.WidthPixels - displayRect.Width(), metrics.HeightPixels); break; // Miss portrait flipped case DisplayOrientations.Portrait: default: NavigationBarRect = new Rect(0, adjustNothingFrame.Bottom, realMetrics.WidthPixels, realMetrics.HeightPixels); break; } KeyboardChanged?.Invoke(keyboardRect); T Get <T>(Action <T> getter) where T : new() { var result = new T(); getter(result); return(result); } } }
public static void InvokeKeyboardChanged(KeyboardState newState) { KeyboardChanged.Invoke(newState); }