IsMousePhysicallyOver() public static method

Returns true whether mouse is physically over the element
public static IsMousePhysicallyOver ( UIElement element ) : bool
element UIElement Element
return bool
Beispiel #1
0
 /// <summary>
 /// Invoked when an unhandled System.Windows.UIElement.PreviewMouseLeftButtonDown routed event
 /// reaches an element in its route that is derived from this class. Implement this method to add
 /// class handling for this event.
 /// </summary>
 /// <param name="e">The System.Windows.Input.MouseButtonEventArgs that contains the event data.
 /// The event data reports that the left mouse button was pressed.</param>
 protected override void OnPreviewMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
 {
     if (!PopupService.IsMousePhysicallyOver(button))
     {
         base.OnPreviewMouseLeftButtonDown(e);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Invoked when an unhandled System.Windows.UIElement.PreviewMouseLeftButtonDown routed event
 /// reaches an element in its route that is derived from this class. Implement this method to add
 /// class handling for this event.
 /// </summary>
 /// <param name="e">The System.Windows.Input.MouseButtonEventArgs that contains the event data.
 /// The event data reports that the left mouse button was pressed.</param>
 protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
 {
     if (!PopupService.IsMousePhysicallyOver(this.button))
     {
         base.OnPreviewMouseLeftButtonDown(e);
     }
     else
     {
         this.IsDropDownOpen = false;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Called when the left mouse button is released.
        /// </summary>
        /// <param name="e">The event data for the <see cref="E:System.Windows.UIElement.MouseLeftButtonUp"/> event.</param>
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            if (e.ClickCount == 1)
            {
                if (this.IsSplited)
                {
                    var buttonBorder = this.GetTemplateChild("PART_ButtonBorder") as Border;
                    if (buttonBorder != null &&
                        PopupService.IsMousePhysicallyOver(buttonBorder))
                    {
                        this.OnClick();
                    }
                }
            }

            base.OnMouseLeftButtonUp(e);
        }
Beispiel #4
0
        /// <inheritdoc />
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            if (e.ClickCount == 1)
            {
                if (this.IsSplited)
                {
                    if (this.GetTemplateChild("PART_ButtonBorder") is Border buttonBorder &&
                        PopupService.IsMousePhysicallyOver(buttonBorder))
                    {
                        this.OnClick();
                    }
                }
                else if (this.HasItems)
                {
                    this.IsSubmenuOpen = !this.IsSubmenuOpen;
                }
            }

            base.OnMouseLeftButtonUp(e);
        }
Beispiel #5
0
        /// <summary>
        /// Handles dismiss popup event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void OnDismissPopup(object sender, DismissPopupEventArgs e)
        {
            IDropDownControl control = sender as IDropDownControl;

            if (control == null)
            {
                return;
            }
            if (e.DismissMode == DismissPopupMode.Always)
            {
                if (Mouse.Captured == control)
                {
                    Mouse.Capture(null);
                }
                // Debug.WriteLine("DropDown Closed");
                control.IsDropDownOpen = false;
            }
            else
            {
                if ((control.IsDropDownOpen) && (!PopupService.IsMousePhysicallyOver(control.DropDownPopup.Child)))
                {
                    if (Mouse.Captured == control)
                    {
                        Mouse.Capture(null);
                    }
                    // Debug.WriteLine("DropDown Closed");
                    control.IsDropDownOpen = false;
                }
                else
                {
                    if ((control.IsDropDownOpen) && (Mouse.Captured != control))
                    {
                        Mouse.Capture(sender as IInputElement, CaptureMode.SubTree);
                    }
                    if (control.IsDropDownOpen)
                    {
                        e.Handled = true;
                    }
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Called when the left mouse button is released.
 /// </summary>
 /// <param name="e">The event data for the <see cref="E:System.Windows.UIElement.MouseLeftButtonUp"/> event.</param>
 protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
 {
     if (e.ClickCount == 1)
     {
         if (this.IsSplited)
         {
             Border buttonBorder = this.GetTemplateChild("PART_ButtonBorder") as Border;
             if ((buttonBorder != null) && (PopupService.IsMousePhysicallyOver(buttonBorder)))
             {
                 /*if (Command != null)
                  * {
                  *  RoutedCommand command = Command as RoutedCommand;
                  *  if (command != null) command.Execute(CommandParameter, CommandTarget);
                  *  else Command.Execute(CommandParameter);
                  * }*/
                 this.OnClick();
             }
         }
     }
     base.OnMouseLeftButtonUp(e);
 }