示例#1
0
        /// <inheritdoc/>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (e.NavigationMethod == NavigationMethod.Directional)
            {
                e.Handled = UpdateSelectionFromEventSource(e.Source);
            }
        }
示例#2
0
 /// <inheritdoc/>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     if (e.NavigationMethod == NavigationMethod.Directional)
     {
         e.Handled = UpdateSelectionFromEventSource(
             e.Source,
             true,
             (e.InputModifiers & InputModifiers.Shift) != 0);
     }
 }
示例#3
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;
            }
        }
示例#4
0
 /// <summary>
 /// Called before the <see cref="GotFocus"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnGotFocus(GotFocusEventArgs e)
 {
     IsFocused = e.Source == this;
 }
示例#5
0
        /// <inheritdoc/>
        protected override void OnGotFocus(GotFocusEventArgs e)
        {
            base.OnGotFocus(e);

            if (e.NavigationMethod == NavigationMethod.Pointer ||
                e.NavigationMethod == NavigationMethod.Directional)
            {
                TrySetSelectionFromContainerEvent(e.Source, true);
            }
        }
示例#6
0
 /// <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);
     this.IsSelected = true;
 }
示例#7
0
文件: TextBox.cs 项目: strogo/Perspex
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     _presenter.ShowCaret();
 }
        public void Focusing_Item_With_Pointer_Should_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = this.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);
        }
        public void Focusing_Item_With_Tab_Should_Not_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = this.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);
        }
示例#10
0
 /// <inheritdoc/>
 protected override void OnGotFocus(GotFocusEventArgs e)
 {
     base.OnGotFocus(e);
     this.TrySetSelectionFromContainerEvent(e.Source, true);
 }
        public void Focusing_Item_Should_Select_It()
        {
            var target = new SelectingItemsControl
            {
                Template = this.Template(),
                Items = new[] { "foo", "bar" },
            };

            target.ApplyTemplate();

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

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

            Assert.Equal(1, target.SelectedIndex);
            Assert.False(e.Handled);
        }
示例#12
0
 /// <summary>
 /// Called before the <see cref="GotFocus"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnGotFocus(GotFocusEventArgs e)
 {
     IsFocused = e.Source == this;
 }
示例#13
0
 protected virtual void OnGotFocus(GotFocusEventArgs e)
 {
     this.IsFocused = e.OriginalSource == this;
     this.SetValue(IsTabFocusedProperty, e.KeyboardNavigated);
 }