コード例 #1
0
ファイル: DropDown.cs プロジェクト: Robertofon/Perspex
 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
ファイル: TabStrip.cs プロジェクト: Arlorean/Perspex
        /// <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);
        }
コード例 #5
0
        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
ファイル: ListBox.cs プロジェクト: rdterner/Perspex
        /// <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
ファイル: TreeView.cs プロジェクト: Robertofon/Perspex
        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
ファイル: MenuItem.cs プロジェクト: MarkWalls/Perspex
        /// <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
ファイル: MouseDevice.cs プロジェクト: rdterner/Perspex
        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
ファイル: MouseDevice.cs プロジェクト: Robertofon/Perspex
        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
ファイル: DropDown.cs プロジェクト: healtech/Perspex
        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
ファイル: DropDown.cs プロジェクト: abdelkarim/Perspex
        /// <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
ファイル: InputElement.cs プロジェクト: Arlorean/Perspex
 /// <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
ファイル: DropDown.cs プロジェクト: furesoft/Perspex
        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);
        }