Beispiel #1
0
 public async Task KeyUp(UIKeyboardEventArgs e)
 {
     if (e.Key == "Enter")
     {
         await SendMessage();
     }
 }
 protected void OnSearchByName(UIKeyboardEventArgs eventArgs)
 {
     if (eventArgs.Key == "Enter" && SearchTerm.Length > 0)
     {
         CategoryService.SearchByName(SearchTerm);
     }
 }
Beispiel #3
0
        public void OnKeyUp(UIKeyboardEventArgs e)
        {
            if (keyPressState.Count == 99)
            {
                keyPressState = new PressState();
                TimerHelper.Stop();
                return;
            }

            string a = e.Key.ToLower();

            if (a.Contains("arrow"))
            {
                MoveDirection CurrDirection = StringToDirection(a.Replace("arrow", null));



                //if (keyPressState.Direction == MoveDirection.undefined)
                //{
                if (!e.CtrlKey)
                {
                    SelectNeightbourCell(CurrDirection);
                }
                //}
                //else
                //{
                //    if (CurrDirection == keyPressState.Direction && keyPressState.Count > 0)
                //    {
                //        SelectNeightbourCell(CurrDirection);
                //    }
                //}
            }
        }
Beispiel #4
0
        private void OnKeyboardDidShow(object sender, UIKeyboardEventArgs e)
        {
            var contentInsets = new UIEdgeInsets(0, 0, e.FrameEnd.Height, 0);

            _scrollView.ContentInset          = contentInsets;
            _scrollView.ScrollIndicatorInsets = contentInsets;
        }
        private void keyboardLowered(object sender, UIKeyboardEventArgs e)
        {
            // setting the phones screen back down now the keyboard has gone
            var mainWindow = UIApplication.SharedApplication.KeyWindow;

            mainWindow.Frame = new CoreGraphics.CGRect(0, 0, mainWindow.Frame.Width, mainWindow.Frame.Height);
        }
Beispiel #6
0
        // Here we will resize and move our UI when Keyboard Shows/Hides
        void KeyboardWillToggle(object sender, UIKeyboardEventArgs e)
        {
            var duration       = e.AnimationDuration;
            var startFrame     = e.FrameBegin;
            var endFrame       = e.FrameEnd;
            int signCorrection = 1;

            if (startFrame.Y < 0 || startFrame.X < 0 || endFrame.Y < 0 || endFrame.X < 0)
            {
                signCorrection = -1;
            }

            var widthChange  = (endFrame.X - startFrame.X) * signCorrection;
            var heightChange = (endFrame.Y - startFrame.Y) * signCorrection;
            //var sizeChange = heightChange; //UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.Portrait ? heightChange : widthChange;
            var sizeChange        = InterfaceOrientation == UIInterfaceOrientation.Portrait ? heightChange : widthChange;
            var newContainerFrame = container.Frame;

            newContainerFrame = new RectangleF(container.Frame.X, container.Frame.Y, container.Frame.Width, container.Frame.Height + sizeChange);
            var offsetY = Math.Max(0.0f, textView.ContentSize.Height - textView.Frame.Size.Height - sizeChange);
            var newTextViewContentOffset = new PointF(0, offsetY);

            UIView.Animate(duration, 0, UIViewAnimationOptions.BeginFromCurrentState, () => container.Frame = newContainerFrame, null);
            textView.SetContentOffset(newTextViewContentOffset, true);
        }
 public void KeyWasPressed(UIKeyboardEventArgs args)
 {
     if (args.Key == "Enter")
     {
         SearchGo();
     }
 }
 private void OnKeyboardHide(object sender, UIKeyboardEventArgs args)
 {
     if (Element != null)
     {
         Element.HeightRequest = 0;
     }
 }
 protected void HandleKeyPress(UIKeyboardEventArgs args, Action action)
 {
     if (args.Key == " " || args.Key == "Enter")
     {
         action?.Invoke();
     }
 }
Beispiel #10
0
        protected override void KeyboardWillShow(object sender, UIKeyboardEventArgs e)
        {
            // this bit of code depends on the knowledge of the component tree:
            // - description label is inside of a container view which is placed in a stack view
            // - we want to know the vertical location of the container view in the whole view
            // - we actually want to know the Y coordinate of the bottom of the container and make
            //   sure we don't overaly it with the keyboard
            var container                   = DescriptionTextView.Superview;
            var absoluteLocation            = View.ConvertPointFromView(container.Frame.Location, container.Superview);
            var minimumVisibleContentHeight = View.Frame.Height - absoluteLocation.Y - container.Frame.Height;

            var coveredByKeyboard = e.FrameEnd.Height - minimumVisibleContentHeight;

            if (coveredByKeyboard < 0)
            {
                return;
            }

            var safeAreaOffset = UIDevice.CurrentDevice.CheckSystemVersion(11, 0)
                ? Math.Max(UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top, UIApplication.SharedApplication.StatusBarFrame.Height)
                : 0;
            var distanceFromTop = Math.Max(safeAreaOffset, View.Frame.Y - coveredByKeyboard);

            View.Frame = new CGRect(View.Frame.X, distanceFromTop, View.Frame.Width, View.Frame.Height);
            UIView.Animate(Animation.Timings.EnterTiming, View.LayoutIfNeeded);
        }
        private void OnKeyboardWillShow(object sender, UIKeyboardEventArgs e)
        {
            if (!IsViewLoaded || _isKeyboardShown)
            {
                return;
            }

            _isKeyboardShown = true;
            var activeView = View.FindFirstResponder();

            if (activeView == null)
            {
                return;
            }
            var keyboardFrame = UIKeyboard.FrameEndFromNotification(e.Notification);
            var isOverlapping = activeView.IsKeyboardOverlapping(View, keyboardFrame);

            if (!isOverlapping)
            {
                return;
            }

            _activeViewBottom = activeView.GetViewRelativeBottom(View);
            ShiftPageUp(keyboardFrame.Height, _activeViewBottom);
        }
Beispiel #12
0
        private void KeyboardShowCallback(object sender, UIKeyboardEventArgs args)
        {
            softKeyboard.Visible = true;
            var screen = UIScreen.MainScreen.Bounds;
            var isOrientationDependent = UIDevice.CurrentDevice.CheckSystemVersion(8, 0) ||
                                         Application.CurrentDeviceOrientation == DeviceOrientation.Portrait;

            if (isOrientationDependent)
            {
                softKeyboard.Height = (float)(screen.Bottom - args.FrameEnd.Top);
            }
            else
            {
                switch (Application.CurrentDeviceOrientation)
                {
                case DeviceOrientation.PortraitUpsideDown:
                    softKeyboard.Height = (float)args.FrameEnd.Bottom;
                    break;

                case DeviceOrientation.LandscapeLeft:
                    softKeyboard.Height = (float)(screen.Right - args.FrameEnd.Left);
                    break;

                case DeviceOrientation.LandscapeRight:
                    softKeyboard.Height = (float)args.FrameEnd.Right;
                    break;
                }
            }
        }
Beispiel #13
0
        System.nfloat GetKeyboardSize(UIKeyboardEventArgs args)
        {
            NSValue result       = (NSValue)args.Notification.UserInfo.ObjectForKey(new NSString(UIKeyboard.FrameEndUserInfoKey));
            CGSize  keyboardSize = result.RectangleFValue.Size;

            return(keyboardSize.Height);
        }
Beispiel #14
0
 void OnHideKeyboard(object sender, UIKeyboardEventArgs args)
 {
     if (Element != null)
     {
         Element.Margin = new Thickness(0);
     }
 }
Beispiel #15
0
 void OnShowKeyboard(object sender, UIKeyboardEventArgs args)
 {
     if (Element != null)
     {
         Element.Margin = new Thickness(0, 0, 0, GetKeyboardSize(args));
     }
 }
Beispiel #16
0
 protected void Escape(UIKeyboardEventArgs e)
 {
     if (e.Key.ToLower() == "escape" && IsOpen == true)
     {
         Dropdown.Hide();
     }
 }
        void UpdateButtomLayoutConstraint(UIKeyboardEventArgs e)
        {
            UIViewAnimationCurve curve = e.AnimationCurve;

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                UIView.Animate(e.AnimationDuration, 0, ConvertToAnimationOptions(e.AnimationCurve), () =>
                {
                    nfloat offsetFromBottom = toolbar.Frame.GetMaxY() - e.FrameEnd.GetMinY();
                    offsetFromBottom        = NMath.Max(0, offsetFromBottom);
                    if (++notifCount >= 2)
                    {
                        SetToolbarContstraint(-offsetFromBottom);
                    }
                }, null);
            }
            else
            {
                UIView.Animate(e.AnimationDuration, 0, ConvertToAnimationOptions(e.AnimationCurve), () =>
                {
                    nfloat offsetFromBottom = tableView.Frame.GetMaxY() - e.FrameEnd.GetMinY();
                    offsetFromBottom        = NMath.Max(0, offsetFromBottom);
                    SetToolbarContstraint(offsetFromBottom);
                }, null);
            }
        }
 public static async Task OnKey(string id, UIKeyboardEventArgs @event)
 {
     if (_terminals.ContainsKey(id))
     {
         await _terminals[id]?.OnKey.InvokeAsync(@event);
     }
 }
        protected override void KeyboardWillShow(object sender, UIKeyboardEventArgs e)
        {
            UIEdgeInsets contentInsets = new UIEdgeInsets(0, 0, e.FrameEnd.Height, 0);

            ScrollView.ContentInset          = contentInsets;
            ScrollView.ScrollIndicatorInsets = contentInsets;
        }
        /// <summary>
        /// Handles view animations when the keyboard is shown.
        /// </summary>
        /// <param name="e">The keyboard arguments for the event.</param>
        public override void AnimateOnShown(UIKeyboardEventArgs e)
        {
            bool shouldHideTopSection;
            int  translateY = this.CalculateVerticalTranslation(e.Notification, out shouldHideTopSection);

            if (translateY < 0)
            {
                Action topSectionAnimation;

                if (shouldHideTopSection)
                {
                    topSectionAnimation = () => this.topSection.Hide();
                }
                else
                {
                    topSectionAnimation = () => ViewAnimation.AnimateMoveVertical(e.AnimationDuration, translateY, this.topSection.Views);
                }

                ViewAnimation.AnimateMoveVertical(
                    e.AnimationDuration,
                    translateY,
                    topSectionAnimation,
                    this.bottomSection.Views);

                shouldAnimateOnHide = true;
            }
            else
            {
                shouldAnimateOnHide = false;
            }
        }
Beispiel #21
0
        public void OnKeyDown(UIKeyboardEventArgs e)
        {
            string a = e.Key.ToLower();

            if (a.Contains("arrow"))
            {
                a = a.Replace("arrow", null);

                switch (a)
                {
                case "right":
                    SelectNeightbourCell(MoveDirection.right, e.CtrlKey);
                    break;

                case "left":
                    SelectNeightbourCell(MoveDirection.left, e.CtrlKey);
                    break;

                case "up":
                    SelectNeightbourCell(MoveDirection.up, e.CtrlKey);
                    break;

                case "down":
                    SelectNeightbourCell(MoveDirection.down, e.CtrlKey);
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #22
0
 protected void MaybeEnter(UIKeyboardEventArgs e)
 {
     if (!string.IsNullOrEmpty(currentTask) && e.Code == "Enter")
     {
         this.AddTask();
     }
 }
        void OnKeyboardShow(object sender, UIKeyboardEventArgs args)
        {
            ReportPage page = Element as ReportPage;

            if (page == null)
            {
                return;
            }

            NSValue result = (NSValue)args.Notification.UserInfo.ObjectForKey(new NSString(UIKeyboard.FrameEndUserInfoKey));

            Console.WriteLine("Show Keyboard ReportPage " + result);
            CGSize keyboardSize = result.RectangleFValue.Size;

            Console.WriteLine(keyboardSize);

            if (savedBounds == false)
            {
                savedBounds = true;
                bounds      = Element.Bounds;
            }

            page.KeyboardChangeHandler(true);

            var newBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Width, App.Current.MainPage.Height - keyboardSize.Height - 100);

            Element.Layout(newBounds);
        }
Beispiel #24
0
        private void OnKeyboardWillShow(object sender, UIKeyboardEventArgs e)
        {
            var keyboardRect = ((NSValue)e.Notification.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey)).RectangleFValue;
            var windowRect   = Windows.UI.Xaml.Window.Current.Bounds;

            _inputPane.OccludedRect = new Rect(0, windowRect.Height - keyboardRect.Height, keyboardRect.Width, keyboardRect.Height);
        }
Beispiel #25
0
 private void OnKeyboardHide(object sender, UIKeyboardEventArgs args)
 {
     if (Element != null)
     {
         Element.Margin = _oldMargin;
     }
 }
Beispiel #26
0
 protected void SearchBoxKeyPress(UIKeyboardEventArgs ev)
 {
     if (ev.Key == "Enter")
     {
         SearchClick();
     }
 }
 public async Task HandleEnterKey(UIKeyboardEventArgs args)
 {
     if (args.Key == "Enter")
     {
         await StartSearch();
     }
 }
Beispiel #28
0
 protected async Task SaveKeyUpEnterAsync(UIKeyboardEventArgs e)
 {
     if (e.Key.ToLower() == "enter")
     {
         await SaveAsync();
     }
 }
Beispiel #29
0
 void OnKeyboardHide(object sender, UIKeyboardEventArgs args)
 {
     //if (Element != null)
     //{
     //    Element.Margin = new Thickness(0); //set the margins to zero when keyboard is dismissed
     //}
 }
Beispiel #30
0
 async Task KeyPress(UIKeyboardEventArgs e)
 {
     Console.WriteLine("KEY:" + e.Key);
     if (e.Key == "Enter")
     {
         await Search();
     }
 }
		private void Scroll (object sender, UIKeyboardEventArgs e, bool scale, bool returnToPreviousState = false)
		{
			UIView.BeginAnimations(string.Empty, IntPtr.Zero);
			UIView.SetAnimationCurve(e.AnimationCurve);
			UIView.SetAnimationDuration(e.AnimationDuration);
			if (returnToPreviousState)
				ChangeFrameSize(false);
			ChangeFrameSize (scale);

			UIView.CommitAnimations();
		}
		void OnKeyboardWillChangeFrame (object sender, UIKeyboardEventArgs keyboardArg)
		{
			// Convert the keyboard frame from screen to view coordinates.
			var keyboardViewBeginFrame = View.ConvertRectFromView (keyboardArg.FrameBegin, View.Window);
			var keyboardViewEndFrame = View.ConvertRectFromView (keyboardArg.FrameEnd, View.Window);
			var originDelta = keyboardViewEndFrame.Y - keyboardViewBeginFrame.Y;

			// The text view should be adjusted, update the constant for this constraint.
			TextViewBottomLayoutGuideConstraint.Constant -= originDelta;
			View.SetNeedsUpdateConstraints ();

			UIView.Animate (keyboardArg.AnimationDuration, 0, UIViewAnimationOptions.BeginFromCurrentState, View.LayoutIfNeeded, null);

			// Scroll to the selected text once the keyboard frame changes.
			NSRange selectedRange = TextView.SelectedRange;
			TextView.ScrollRangeToVisible (selectedRange);
		}
		void KeyboardHideHandler (object sender, UIKeyboardEventArgs e)
		{
			GoToNormalLayout ();
		}
		void OnKeyboardNotification (UIKeyboardEventArgs e)
		{
			//Check if the keyboard is becoming visible
			bool willShow = e.Notification.Name == UIKeyboard.WillShowNotification;

			//Start an animation, using values from the keyboard
			UIView.BeginAnimations("AnimateForKeyboard");
			UIView.SetAnimationDuration(e.AnimationDuration);
			UIView.SetAnimationCurve(e.AnimationCurve);

			//Calculate keyboard height, etc.
			if (willShow)
			{
				var keyboardFrame = e.FrameEnd;
				var frame = TableView.Frame;
				frame.Height -= keyboardFrame.Height;
				TableView.Frame = frame;
				frame = toolbar.Frame;
				frame.Y -= keyboardFrame.Height;
				toolbar.Frame = frame;
			}
			else
			{
				var keyboardFrame = e.FrameBegin;
				var frame = TableView.Frame;
				frame.Height += keyboardFrame.Height;
				TableView.Frame = frame;
				frame = toolbar.Frame;
				frame.Y += keyboardFrame.Height;
				toolbar.Frame = frame;
			}

			//Commit the animation
			UIView.CommitAnimations();
			ScrollToEnd();
		}
 void UpdateButtomLayoutConstraint(UIKeyboardEventArgs e)
 {
     UIViewAnimationCurve curve = e.AnimationCurve;
     UIView.Animate (e.AnimationDuration, 0, ConvertToAnimationOptions (e.AnimationCurve), () => {
         nfloat offsetFromBottom = tableView.Frame.GetMaxY () - e.FrameEnd.GetMinY ();
         offsetFromBottom = NMath.Max (0, offsetFromBottom);
         SetToolbarContstraint (offsetFromBottom);
     }, null);
 }
Beispiel #36
0
		static void OnKeyboardHidden(object sender, UIKeyboardEventArgs args)
		{
			var handler = KeyboardWillHide;
			if (handler != null)
				handler(sender, args);
		}
		void UpdateButtomLayoutConstraint(UIKeyboardEventArgs e)
		{
			UIViewAnimationCurve curve = e.AnimationCurve;
			UIView.Animate (e.AnimationDuration, 0, ConvertToAnimationOptions (e.AnimationCurve), () => {
//				SetToolbarContstraint(tableView.Frame.GetMaxY () - e.FrameEnd.GetMinY ());
				SetToolbarContstraint(e.FrameEnd.Height);

				// Move content with keyboard
				/*
				var oldOverlap = CalcContentOverlap();
				UpdateTableInsets ();
				var newOverlap = CalcContentOverlap();

				var offset = tableView.ContentOffset;
				offset.Y += newOverlap - oldOverlap;
				offset.Y = NMath.Max(offset.Y, 0);
				tableView.ContentOffset = offset;
				*/
			}, null);
		}
		void KeyboardWillHideHandler (object sender, UIKeyboardEventArgs e)
		{
			UpdateButtomLayoutConstraint (e);
		}
        //
        // When the keyboard appears, animate the new position for the entry
        // and scroll the chat to the bottom
        //
        void PlaceKeyboard(object sender, UIKeyboardEventArgs args)
        {
            UIView.BeginAnimations (""); {
                UIView.SetAnimationCurve (args.AnimationCurve);
                UIView.SetAnimationDuration (args.AnimationDuration);
                var viewFrame = View.Frame;
                var endRelative = View.ConvertRectFromView (args.FrameEnd, null);
                viewFrame.Height = endRelative.Y;
                View.Frame = viewFrame;
            } UIView.CommitAnimations ();

            ScrollToBottom (true);
            AdjustEntry ();
        }
Beispiel #40
0
		static void OnKeyboardShown(object sender, UIKeyboardEventArgs args)
		{
			var handler = KeyboardWillShow;
			if (handler != null)
				handler(sender, args);
		}
		void KeyboardShowHandler (object sender, UIKeyboardEventArgs e)
		{
			blendViewNormalHeight = NavBarBlendViewHeightConstraint.Constant;
			var keyboardEdge = View.Bounds.Height - e.FrameEnd.Height;

			// verticat space between Input and ContinueBtn
			var h = ContinueBtn.Frame.GetMinY () - Input.Frame.GetMaxY ();

			if (ContinueBtn.Frame.GetMaxY () + h > keyboardEdge) {
				nfloat continueBtnBottomOfsset = e.FrameEnd.Height + h;
				GoToCompactLayout (continueBtnBottomOfsset);
			}
		}
		void OnKeyboardShown(object sender, UIKeyboardEventArgs args)
		{
			_lastKeyboardRect = args.FrameEnd;
			UpdateInsets();
		}
        // Here we will resize and move our UI when Keyboard Shows/Hides
        void KeyboardWillToggle(object sender, UIKeyboardEventArgs e)
        {
            var duration = e.AnimationDuration;
            var startFrame = e.FrameBegin;
            var endFrame = e.FrameEnd;
            int signCorrection = 1;

            if (startFrame.Y < 0 || startFrame.X < 0 || endFrame.Y < 0 || endFrame.X < 0)
                signCorrection = -1;

            var widthChange = (endFrame.X - startFrame.X) * signCorrection;
            var heightChange = (endFrame.Y - startFrame.Y) * signCorrection;
            //var sizeChange = heightChange; //UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.Portrait ? heightChange : widthChange;
            var sizeChange = InterfaceOrientation == UIInterfaceOrientation.Portrait ? heightChange : widthChange;
            var newContainerFrame = container.Frame;
            newContainerFrame = new RectangleF (container.Frame.X, container.Frame.Y, container.Frame.Width, container.Frame.Height + sizeChange);
            var offsetY = Math.Max (0.0f, textView.ContentSize.Height - textView.Frame.Size.Height - sizeChange);
            var newTextViewContentOffset = new PointF (0, offsetY);
            UIView.Animate (duration, 0, UIViewAnimationOptions.BeginFromCurrentState, () => container.Frame = newContainerFrame, null);
            textView.SetContentOffset (newTextViewContentOffset, true);
        }
		void OnKeyboardHidden(object sender, UIKeyboardEventArgs args)
		{
			_setInsetAction(new UIEdgeInsets(0, 0, 0, 0));
			_lastKeyboardRect = RectangleF.Empty;
		}
		private void OnKeyboardNotification (UIKeyboardEventArgs e)
		{
			KeyboardVisible = e.Notification.Name == UIKeyboard.WillShowNotification;
		}