Ejemplo n.º 1
0
        private void OnGotFocus(object?sender, GotFocusEventArgs e)
        {
            InterceptKeys.Run();
            _vm.HotKey = new HotKey();

            InterceptKeys.KeyDown += key => {
                if (key == (int)Keys.Delete)
                {
                    ClearHotKey();
                    return;
                }

                if (KeyState.DefaultModifiers.Contains(key) &&
                    _vm.HotKey.Modifiers.All(x => x != key))
                {
                    _vm.HotKey.Modifiers.Add(key);
                }
                else if (!KeyState.DefaultModifiers.Contains(key))
                {
                    _vm.HotKey.Key = key;
                }

                _vm.SetKeys();
            };
        }
        private void enlargeBox(object sender, GotFocusEventArgs e)
        {
            TextBox senderbox = (TextBox)sender;

            senderbox.Width    = 700;
            senderbox.FontSize = senderbox.FontSize * 2;
        }
        /**
         * choose directory
         */
        public async void selectDir(Object sender, GotFocusEventArgs e)
        {
            var task = await new OpenFolderDialog().ShowAsync(this);
            var tbx  = sender as TextBox;

            tbx.Text = task;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called before the <see cref="InputElement.GotFocus"/> event occurs.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (IsFocused &&
                (e.NavigationMethod == NavigationMethod.Tab ||
                 e.NavigationMethod == NavigationMethod.Directional))
            {
                var adornerLayer = AdornerLayer.GetAdornerLayer(this);

                if (adornerLayer != null)
                {
                    if (_focusAdorner == null)
                    {
                        var template = GetValue(FocusAdornerProperty);

                        if (template != null)
                        {
                            _focusAdorner = template.Build();
                        }
                    }

                    if (_focusAdorner != null)
                    {
                        var target = (Visual)GetTemplateFocusTarget();

                        if (target != null)
                        {
                            AdornerLayer.SetAdornedElement((Visual)_focusAdorner, target);
                            adornerLayer.Children.Add(_focusAdorner);
                        }
                    }
                }
            }
        }
        private void OnTextBoxGotFocus(object sender, GotFocusEventArgs args)
        {
            var textBox = (TextBox)sender;

            m_isFocusedTextBoxValid = true;
            m_previousString        = textBox.Text;
        }
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            Terminal?.FocusIn();

            InvalidateVisual();
        }
Ejemplo n.º 7
0
 protected void SelectTextOnFocus(object sender, GotFocusEventArgs e)
 {
     if (!(sender is TextBox textBox))
     {
         return;
     }
     textBox.SelectionStart = 0;
     textBox.SelectionEnd   = textBox.Text?.Length ?? 0;
 }
        /// <summary>
        /// Raise the GotFocus event
        /// </summary>
        /// <param name="eventArgs"></param>
        protected virtual void OnGotFocus(GotFocusEventArgs eventArgs)
        {
            EventHandler <GotFocusEventArgs> handler = GotFocus;

            if (handler != null)
            {
                handler(this, eventArgs);
            }
        }
Ejemplo n.º 9
0
 protected internal override void OnGotFocus(GotFocusEventArgs args)
 {
     base.OnGotFocus(args);
     ScreenEngine.Instance.RequestKeyboard(InputScope);
     if (ScreenEngine.Instance.CurrentKeyboard != null)
     {
         ScreenEngine.Instance.CurrentKeyboard.Control.KeyPressed += HandleKeyPressed;
     }
 }
        protected internal virtual void GotFocus(object sender, GotFocusEventArgs e)
        {
            var item = GetMenuItem(e.Source as IControl);

            if (item?.Parent != null)
            {
                item.SelectedItem = item;
            }
        }
Ejemplo n.º 11
0
        /// <inheritdoc/>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (e.NavigationMethod == NavigationMethod.Directional)
            {
                e.Handled = UpdateSelectionFromEventSource(e.Source);
            }
        }
Ejemplo n.º 12
0
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     if (_thumb != null &&
         ToolTip.GetTip(_thumb) is ToolTip toolTip)
     {
         toolTip.Content = GetToolTipString();
         ToolTip.SetIsOpen(_thumb, true);
     }
 }
Ejemplo n.º 13
0
        private void txtFplId_GotFocus(object sender, GotFocusEventArgs e)
        {
            TextBox tb = (TextBox)sender;

            tb.Text       = string.Empty;
            tb.Foreground = Brushes.Black;
            tb.GotFocus  -= txtDestICAO_GotFocus;

            textFieldFocused = true;
        }
Ejemplo n.º 14
0
        /// <inheritdoc/>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (e.NavigationMethod == NavigationMethod.Pointer ||
                e.NavigationMethod == NavigationMethod.Directional)
            {
                TrySetSelectionFromContainerEvent(e.Source, true);
            }
        }
Ejemplo n.º 15
0
 /// <inheritdoc/>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     if (e.NavigationMethod == NavigationMethod.Directional)
     {
         e.Handled = UpdateSelectionFromEventSource(
             e.Source,
             true,
             (e.InputModifiers & InputModifiers.Shift) != 0);
     }
 }
Ejemplo n.º 16
0
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            var control = (IControl)e.Source;
            var item    = ItemContainerGenerator.ItemFromContainer(control);

            if (item != null)
            {
                SelectedItem = item;
                e.Handled    = true;
            }
        }
Ejemplo n.º 17
0
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            if (!HasText)
            {
                TextBlock wl = (TextBlock)this.FindControl <TextBlock>("WatermarkLabel");
                if (wl != null)
                {
                    wl.IsVisible = false;
                }
            }

            base.OnGotFocus(e);
        }
Ejemplo n.º 18
0
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     if (IsEnabled && _textBox != null && e.NavigationMethod == NavigationMethod.Tab)
     {
         _textBox.Focus();
         var text = _textBox.Text;
         if (!string.IsNullOrEmpty(text))
         {
             _textBox.SelectionStart = 0;
             _textBox.SelectionEnd   = text.Length;
         }
     }
 }
Ejemplo n.º 19
0
        private void OnGotFocus(object?sender, GotFocusEventArgs e)
        {
            _vm.Keys = new AvaloniaList <byte>();

            InterceptKeys.KeyDown += key => {
                if (key == (int)Keys.Delete)
                {
                    _vm.Keys = new AvaloniaList <byte>();
                    _vm.SetKeys();
                    return;
                }

                _vm.Keys.Add((byte)key);
                _vm.SetKeys();
            };
        }
Ejemplo n.º 20
0
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            // when navigating to a textbox via the tab key, select all text if
            //   1) this textbox is *not* a multiline textbox
            //   2) this textbox has any text to select
            if (e.NavigationMethod == NavigationMethod.Tab &&
                !AcceptsReturn &&
                Text?.Length > 0)
            {
                SelectionStart = 0;
                SelectionEnd   = Text.Length;
            }
            else
            {
                _presenter?.ShowCaret();
            }
        }
Ejemplo n.º 21
0
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            // Call The TabInto method when the control gots focus to
            // let the native window handle getting focus.
            Contract.Requires <ArgumentNullException>(e != null);

            NavigationMethod direction;

//			if (e.InputModifiers == InputModifiers.Shift)
//				direction = NavigationMethod.Previous;
//			else
//				direction = NavigationMethod.Next;
//
//			var handled = ((IKeyboardInputSink)this).TabInto(direction);
//			if (handled)
//				e.Handled = handled;

            base.OnGotFocus(e);
        }
Ejemplo n.º 22
0
        public void Focusing_Item_With_Tab_Should_Not_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = Template(),
                Items    = new[] { "foo", "bar" },
            };

            target.ApplyTemplate();

            var e = new GotFocusEventArgs
            {
                RoutedEvent      = InputElement.GotFocusEvent,
                NavigationMethod = NavigationMethod.Tab,
            };

            target.Presenter.Panel.Children[1].RaiseEvent(e);

            Assert.Equal(-1, target.SelectedIndex);
        }
Ejemplo n.º 23
0
        public void Focusing_Item_With_Pointer_Should_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = Template(),
                Items    = new[] { "foo", "bar" },
            };

            target.ApplyTemplate();

            var e = new GotFocusEventArgs
            {
                RoutedEvent      = InputElement.GotFocusEvent,
                NavigationMethod = NavigationMethod.Pointer,
            };

            target.Presenter.Panel.Children[1].RaiseEvent(e);

            Assert.Equal(1, target.SelectedIndex);

            // GotFocus should be raised on parent control.
            Assert.False(e.Handled);
        }
 /// <summary>
 /// Called when the <see cref="MenuItem"/> recieves focus.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     IsSelected = true;
 }
Ejemplo n.º 25
0
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     TextArea.Focus();
     e.Handled = true;
 }
Ejemplo n.º 26
0
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     _presenter.ShowCaret();
 }
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     FocusedChanged?.Invoke(new FocusedChangedEventArgs(true));
 }
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     lastFocusTime = DateTime.Now;
     SelectAll();
 }
Ejemplo n.º 29
0
 /// <inheritdoc/>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     e.Handled = UpdateSelectionFromEventSource(e.Source, true);
 }
 /// <summary>
 /// When the TopicFilterTextBox gets focus, override the stored filter with its current value.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TopicFilterTextBox_GotFocus(object sender, GotFocusEventArgs e)
 {
     topicBefore = topicFilterTextBox.Text;
 }