Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Moving the title bar will affect the left mouse click event in the diagram (Read 3206 times)
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Moving the title bar will affect the left mouse click event in the diagram
Mar 30th, 2020 at 8:07am
Print Post  
I currently use this code to move the title bar, but it will affect the drag of ShapeNode in Diagram. How can I solve it?

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
Point position = e.GetPosition(this);
if (e.LeftButton == MouseButtonState.Pressed)
{
if (position.X >= 0 && position.X < this.ActualWidth && position.Y >= 0 && position.Y < this.ActualHeight)
{
this.DragMove();
}
}
}
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #1 - Mar 30th, 2020 at 9:58am
Print Post  
Hi,

I'm not entirely sure what you're trying to achieve or what exactly your problem is, but if you want to prevent the diagram of receiving the mouse event when a certain criteria of yours is met, you can handle the PreviewMouseLeftButtonDown event instead, and set the MouseButtonEventArgs Handled property to true. That way  the diagram won't receive that particular message and dragging of nodes won't occur.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #2 - Mar 30th, 2020 at 10:20am
Print Post  
The menu bar doesn't open after I use it

private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
#region 边框窗体拖动
base.OnMouseLeftButtonDown(e);
// 获取 相对 题 位置
Point position = e.GetPosition(this);
// 如果 位置在 题 内,允许拖动
if (e.LeftButton == MouseButtonState.Pressed)
{
if (position.X >= 0 && position.X < this.ActualWidth && position.Y >= 0 && position.Y < this.ActualHeight)
{
this.DragMove();
}
}
e.Handled = true;
#endregion
}
  

3_30_7.png (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #3 - Mar 30th, 2020 at 10:59am
Print Post  
Hi,

You're not supposed to call e.Handled each time the handler is invoked as the event will never reach your menu item.

But again, I don't really understand what you're trying to achieve with this, so if you need further help with this, please try to elaborate your issue better.

What your code currently tries to do is to drag the whole window not only from the tile strip, but from anywhere within its bounds.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #4 - Mar 30th, 2020 at 11:23am
Print Post  
Smiley My requirement is that after clicking the title bar of the window with the left mouse button, the entire window can be dragged without releasing it, but it will not affect the click event of the left mouse button of Diagram. How can I do this?
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #5 - Mar 30th, 2020 at 12:50pm
Print Post  
Hi,

The behavior you describe is already existing in the operating system and the WPF framework. It should not require any additional code to achieve.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #6 - Mar 30th, 2020 at 12:59pm
Print Post  
Doesn't work because I set WindowStyle = "None", I just want to drag the title bar without affecting the Diagram.
  

3_30_10.png (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #7 - Mar 30th, 2020 at 1:15pm
Print Post  
Hi,

Should have started with that Smiley. Remove the PreviewMouseLeftButtonDown handler and use your existing MouseLeftButtonDown one, but limit the constraint to the actual height of your title bar / panel, not the entire window. Something like:
Code
Select All
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);
            Point position = e.GetPosition(this);
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (position.X >= 0 && position.X <= this.ActualWidth && position.Y >= 0 && position.Y <= myTitleHeight)
                {
                    this.DragMove();
                    e.Handled = true;
                }
            }
        }
 



Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Moving the title bar will affect the left mouse click event in the diagram
Reply #8 - Mar 30th, 2020 at 1:24pm
Print Post  
Thanks a lot, Lyubo. Smiley
You are amazing! Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint