示例#1
0
 protected override void OnPointerPressed(PointerPressEventArgs e)
 {
     if (!this.IsDropDownOpen)
     {
         this.IsDropDownOpen = true;
     }
 }
示例#2
0
        private void MouseDown(IMouseDevice device, uint timestamp, IInputElement root, Point p)
        {
            var hit = HitTest(root, p);

            if (hit != null)
            {
                IInteractive source = GetSource(hit);

                if (source != null)
                {
                    var settings        = Locator.Current.GetService <IPlatformSettings>();
                    var doubleClickTime = settings.DoubleClickTime.TotalMilliseconds;

                    if (!_lastClickRect.Contains(p) || timestamp - _lastClickTime > doubleClickTime)
                    {
                        _clickCount = 0;
                    }

                    ++_clickCount;
                    _lastClickTime = timestamp;
                    _lastClickRect = new Rect(p, new Size())
                                     .Inflate(new Thickness(settings.DoubleClickSize.Width / 2, settings.DoubleClickSize.Height / 2));

                    var e = new PointerPressEventArgs
                    {
                        Device      = this,
                        RoutedEvent = InputElement.PointerPressedEvent,
                        Source      = source,
                        ClickCount  = _clickCount,
                    };

                    source.RaiseEvent(e);
                }
            }
        }
示例#3
0
        /// <inheritdoc/>
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            base.OnPointerPressed(e);

            if (e.MouseButton == MouseButton.Left)
            {
                e.Handled = UpdateSelectionFromEventSource(e.Source);
            }
        }
示例#4
0
文件: Thumb.cs 项目: healtech/Perspex
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            e.Device.Capture(this);
            _lastPoint = e.GetPosition(this);

            var ev = new VectorEventArgs
            {
                RoutedEvent = DragStartedEvent,
                Vector = (Vector)_lastPoint,
            };

            RaiseEvent(ev);
        }
        public void PointerPressed_Event_Should_Be_Handled()
        {
            var target = new Target();

            var e = new PointerPressEventArgs
            {
                RoutedEvent = InputElement.PointerPressedEvent
            };

            target.RaiseEvent(e);

            Assert.True(e.Handled);
        }
示例#6
0
        /// <inheritdoc/>
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            base.OnPointerPressed(e);

            if (e.MouseButton == MouseButton.Left || e.MouseButton == MouseButton.Right)
            {
                e.Handled = UpdateSelectionFromEventSource(
                    e.Source,
                    true,
                    (e.InputModifiers & InputModifiers.Shift) != 0,
                    (e.InputModifiers & InputModifiers.Control) != 0);
            }
        }
示例#7
0
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            IVisual source = (IVisual)e.Source;
            var selectable = source.GetVisualAncestors()
                .OfType<ISelectable>()
                .OfType<Control>()
                .FirstOrDefault();

            if (selectable != null)
            {
                var item = this.ItemContainerGenerator.ItemFromContainer(selectable);

                if (item != null)
                {
                    this.SelectedItem = item;
                    selectable.BringIntoView();
                    FocusManager.Instance.Focus(selectable);
                }
            }

            e.Handled = true;
        }
示例#8
0
        /// <summary>
        /// Called when the pointer is pressed over the <see cref="MenuItem"/>.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            base.OnPointerPressed(e);

            if (!this.HasSubMenu)
            {
                this.RaiseEvent(new RoutedEventArgs(ClickEvent));
            }
            else if (this.IsTopLevel)
            {
                this.IsSubMenuOpen = !this.IsSubMenuOpen;
            }
            else
            {
                this.IsSubMenuOpen = true;
            }

            e.Handled = true;
        }
示例#9
0
文件: Button.cs 项目: Scellow/Perspex
        /// <inheritdoc/>
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            base.OnPointerPressed(e);

            this.Classes.Add(":pressed");
            e.Device.Capture(this);
            e.Handled = true;

            if (this.ClickMode == ClickMode.Press)
            {
                this.RaiseClickEvent();
            }
        }
示例#10
0
文件: TextBox.cs 项目: strogo/Perspex
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            if (e.Source == _presenter)
            {
                var point = e.GetPosition(_presenter);
                var index = CaretIndex = _presenter.GetCaretIndex(point);
                var text = Text;

                switch (e.ClickCount)
                {
                    case 1:
                        SelectionStart = SelectionEnd = index;
                        break;
                    case 2:
                        if (!StringUtils.IsStartOfWord(text, index))
                        {
                            SelectionStart = StringUtils.PreviousWord(text, index, false);
                        }

                        SelectionEnd = StringUtils.NextWord(text, index, false);
                        break;
                    case 3:
                        SelectionStart = 0;
                        SelectionEnd = text.Length;
                        break;
                }

                e.Device.Capture(_presenter);
                e.Handled = true;
            }
        }
示例#11
0
        private void MouseDown(IMouseDevice device, uint timestamp, IInputElement root, Point p, MouseButton button, InputModifiers inputModifiers)
        {
            var hit = HitTest(root, p);

            if (hit != null)
            {
                IInteractive source = GetSource(hit);

                if (source != null)
                {
                    var settings = PerspexLocator.Current.GetService<IPlatformSettings>();
                    var doubleClickTime = settings.DoubleClickTime.TotalMilliseconds;

                    if (!_lastClickRect.Contains(p) || timestamp - _lastClickTime > doubleClickTime)
                    {
                        _clickCount = 0;
                    }

                    ++_clickCount;
                    _lastClickTime = timestamp;
                    _lastClickRect = new Rect(p, new Size())
                        .Inflate(new Thickness(settings.DoubleClickSize.Width / 2, settings.DoubleClickSize.Height / 2));

                    var e = new PointerPressEventArgs
                    {
                        Device = this,
                        RoutedEvent = InputElement.PointerPressedEvent,
                        Source = source,
                        ClickCount = _clickCount,
                        MouseButton = button,
                        InputModifiers = inputModifiers
                    };

                    source.RaiseEvent(e);
                }
            }
        }
示例#12
0
文件: Deck.cs 项目: Scellow/Perspex
 /// <inheritdoc/>
 protected override void OnPointerPressed(PointerPressEventArgs e)
 {
     // Ignore pointer presses.
 }
示例#13
0
        private void MouseDown(IMouseDevice device, uint timestamp, IInputElement root, Point p)
        {
            var hit = this.HitTest(root, p);

            if (hit != null)
            {
                IInteractive source = this.GetSource(hit);

                if (source != null)
                {
                    var settings = Locator.Current.GetService<IPlatformSettings>();
                    var doubleClickTime = settings.DoubleClickTime.TotalMilliseconds;

                    if (!this.lastClickRect.Contains(p) || timestamp - this.lastClickTime > doubleClickTime)
                    {
                        this.clickCount = 0;
                    }

                    ++this.clickCount;
                    this.lastClickTime = timestamp;
                    this.lastClickRect = new Rect(p, new Size())
                        .Inflate(new Thickness(settings.DoubleClickSize.Width / 2, settings.DoubleClickSize.Height / 2));

                    var e = new PointerPressEventArgs
                    {
                        Device = this,
                        RoutedEvent = InputElement.PointerPressedEvent,
                        OriginalSource = source,
                        Source = source,
                        ClickCount = this.clickCount,
                    };

                    source.RaiseEvent(e);
                }
            }
        }
示例#14
0
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            if (!IsDropDownOpen)
            {
                if (((IVisual)e.Source).GetVisualAncestors().Last().GetType() != typeof(PopupRoot))
                {
                    IsDropDownOpen = true;
                }
            }

            base.OnPointerPressed(e);
        }
示例#15
0
 /// <inheritdoc/>
 protected override void OnPointerPressed(PointerPressEventArgs e)
 {
     base.OnPointerPressed(e);
     e.Handled = true;
 }
示例#16
0
文件: Menu.cs 项目: MarkWalls/Perspex
        /// <summary>
        /// Called when the pointer is pressed anywhere on the window.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event args.</param>
        private void TopLevelPreviewPointerPress(object sender, PointerPressEventArgs e)
        {
            if (this.IsOpen)
            {
                var control = e.Source as ILogical;

                if (!this.IsLogicalParentOf(control))
                {
                    this.Close();
                }
            }
        }
示例#17
0
 /// <summary>
 /// Called before the <see cref="PointerPressed"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnPointerPressed(PointerPressEventArgs e)
 {
 }
示例#18
0
文件: Popup.cs 项目: alimbada/Perspex
        private void PointerPressedOutside(object sender, PointerPressEventArgs e)
        {
            if (!StaysOpen)
            {
                var root = ((IVisual)e.Source).GetVisualRoot();

                if (root != this.PopupRoot)
                {
                    Close();
                    e.Handled = true;
                }
            }
        }
示例#19
0
        /// <inheritdoc/>
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            if (!IsDropDownOpen && ((IVisual)e.Source).GetVisualRoot() != typeof(PopupRoot))
            {
                IsDropDownOpen = true;
                e.Handled = true;
            }

            if (!e.Handled)
            {
                if (UpdateSelectionFromEventSource(e.Source))
                {
                    _popup?.Close();
                    e.Handled = true;
                }
            }

            base.OnPointerPressed(e);
        }
示例#20
0
 /// <summary>
 /// Called before the <see cref="PointerPressed"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnPointerPressed(PointerPressEventArgs e)
 {
 }
示例#21
0
        protected override void OnPointerPressed(PointerPressEventArgs e)
        {
            if (!IsDropDownOpen)
            {
                if (((IVisual)e.Source).GetVisualAncestors().Last().GetType() != typeof(PopupRoot))
                {
                    IsDropDownOpen = true;
                    e.Handled = true;
                }
            }

            if (!e.Handled)
            {
                if (UpdateSelectionFromEventSource(e.Source))
                {
                    e.Handled = true;
                }
            }

            base.OnPointerPressed(e);
        }