protected override void OnKeyPress(object sender, DialogKeyEventArgs args)
 {
     base.OnKeyPress(sender, args);
     if (args.KeyCode != Keycode.Back)
     {
         args.Handled = false;
         return;
     }
     args.Handled = true;
     Config?.OnAction(new LoginResult(false, null, null));
     Dismiss();
 }
Exemple #2
0
        protected override void OnKeyPress(object sender, DialogKeyEventArgs args)
        {
            base.OnKeyPress(sender, args);
            if (args.KeyCode != Keycode.Back)
            {
                return;
            }

            args.Handled = true;
            this.Config?.OnAction?.Invoke();
            this.Dismiss();
        }
Exemple #3
0
        protected override void OnKeyPress(object sender, DialogKeyEventArgs args)
        {
            base.OnKeyPress(sender, args);

            if (args.KeyCode != Android.Views.Keycode.Back)
            {
                return;
            }

            args.Handled = true;

            this.Dismiss();
        }
        protected override void OnKeyPress(object sender, DialogKeyEventArgs args)
        {
            base.OnKeyPress(sender, args);

            if (args.KeyCode == Android.Views.Keycode.Back)
            {
                args.Handled = true;

                this.Config?.Action?.Invoke(false);

                this.Dismiss();
            }
        }
        /// <summary>
        /// Observes for HwndSource changes on the given UIElement, and adds and removes an HwndSource hook when the HwndSource changes.</summary>
        private void HookChildHwndSource(UIElement child)
        {
            // The delegate reference is stored on the UIElement, and the lifetime
            // of the child is equal to the lifetime of this UIElementDialogPage,
            // so we are not leaking memory by not calling RemoveSourceChangedHandler.
            PresentationSource.AddSourceChangedHandler(child, OnSourceChanged);
            void OnSourceChanged(object sender, SourceChangedEventArgs e)
            {
                if (e.OldSource is HwndSource old_source)
                {
                    old_source.RemoveHook(SourceHook);
                }
                if (e.NewSource is HwndSource new_source)
                {
                    new_source.AddHook(SourceHook);
                }
            }

            IntPtr SourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
            {
                // Handle WM_GETDLGCODE in order to allow for arrow and tab navigation inside the dialog page.
                // By returning this code, Windows will pass arrow and tab keys to our HWND instead of handling
                // them for its own default tab and directional navigation.
                switch (msg)
                {
                case Win32.WM_GETDLGCODE:
                {
                    int dlg_code = Win32.DLGC_WANTARROWS | Win32.DLGC_WANTTAB | Win32.DLGC_WANTCHARS;

                    // Ask the currently-focused element if it wants to handle all keys or not.  The DialogKeyPendingEvent
                    // is a routed event starting with the focused control.  If any control in the route handles
                    // this message, then we'll add DLGC_WANTALLKEYS to request that this pending message
                    // be delivered to our content instead of the default dialog procedure.
                    if (Keyboard.FocusedElement is IInputElement current_element)
                    {
                        var args = new DialogKeyEventArgs(DialogKeyPendingEvent, KeyInterop.KeyFromVirtualKey(wParam.ToInt32()));
                        current_element.RaiseEvent(args);
                        if (args.Handled)
                        {
                            dlg_code |= Win32.DLGC_WANTALLKEYS;
                        }
                    }

                    handled = true;
                    return(new IntPtr(dlg_code));
                }
                }

                return(IntPtr.Zero);
            }
        }
Exemple #6
0
        protected override void OnKeyPress(object sender, DialogKeyEventArgs args)
        {
            base.OnKeyPress(sender, args);
            if (args.KeyCode != Keycode.Back)
            {
                return;
            }

            args.Handled = true;
            if (this.Config.IsCancellable)
            {
                this.Config?.OnAction?.Invoke(new TimePromptResult(false, TimeSpan.MinValue));
                this.Dismiss();
            }
        }
 protected override void Dialog_KeyPress(object sender, DialogKeyEventArgs e)
 {
     if (e.KeyCode == Keycode.Back)
     {
         if (e.Event.Action == KeyEventActions.Up)
         {
             if (ValidateExit(true))
             {
                 e.Handled = true;
             }
             else
             {
                 e.Handled = false;
             }
         }
     }
     else
     {
         e.Handled = false;
     }
 }
Exemple #8
0
        protected override void OnKeyPress(object sender, DialogKeyEventArgs args)
        {
            base.OnKeyPress(sender, args);
            args.Handled = false;

            switch (args.KeyCode)
            {
            case Keycode.Back:
                args.Handled = true;
                if (this.Config.IsCancellable)
                {
                    this.SetAction(false);
                }
                break;

            case Keycode.Enter:
                args.Handled = true;
                this.SetAction(true);
                break;
            }
        }
 protected virtual void OnKeyPress(object sender, DialogKeyEventArgs args)
 {
 }
 protected virtual void Dialog_KeyPress(object sender, DialogKeyEventArgs e)
 {
 }