Jump to content
  • Advertisement
Sign in to follow this  
Headkaze

[.net] MouseUp event triggered on titlebar doubleclick

This topic is 3028 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When a user double clicks on a window's titlebar a MouseUp event is triggered. It doesn't make sense to me that this event is triggered. Does anyone know of a simple fix for this? Perhaps a way to detect the resizing of the window to ignore MouseUp event during this period? [Edited by - Headkaze on April 3, 2010 1:39:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
I made a mistake in my original post. The message is MouseUp not MouseDown.

To replicate the behaviour start a new project in Visual Studio and add a MouseUp event.

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
MessageBox.Show("MouseUp");
}


Run it and double click on the titlebar to maximize the window and it should display the message box.

Share this post


Link to post
Share on other sites
Yes, that is what I saw in my experiment too.

The only solution I see is by subscribing to the SizeChanged event and checking there whether the form got maximized (WindowState). If so, set a bool and check for the bool in the mouseup, resetting it when it was set. That way you ignore the MouseUp from the resize.

It's a hack but the only thing I could come up with.

using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private bool _justMaximized = false;

public Form1()
{
InitializeComponent();
}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (_justMaximized)
{
_justMaximized = false;
return;
}
Debug.WriteLine("MouseUp");
}

private void Form1_SizeChanged(object sender, EventArgs e)
{
Debug.WriteLine("SizeChanged");
_justMaximized = (WindowState == FormWindowState.Maximized);
}

}
}




[Edited by - ernow on April 3, 2010 10:25:11 AM]

Share this post


Link to post
Share on other sites
It's probably happening because by the time you release the second click, the form has already maximized, and your mouse is now within the context of the form, thus you receive a MouseUp event.

Share this post


Link to post
Share on other sites
Quote:
Original post by Flimflam
It's probably happening because by the time you release the second click, the form has already maximized, and your mouse is now within the context of the form, thus you receive a MouseUp event.


Let's face it, it's a bug. Thanks for the example ernow.

Share this post


Link to post
Share on other sites
Quote:
Original post by Headkaze
Let's face it, it's a bug. Thanks for the example ernow.


Nope, it is working exactly the way it is suppose to. It is not a bug, it is expected action.

theTroll

Share this post


Link to post
Share on other sites
Quote:
Original post by TheTroll
Nope, it is working exactly the way it is suppose to. It is not a bug, it is expected action.


I don't agree. There is no possible purpose this could be useful. Even so this behaviour has been annoying on at least 3 apps I've written that use the mouse for drawing.

Share this post


Link to post
Share on other sites
Quote:
Original post by Headkaze
Quote:
Original post by TheTroll
Nope, it is working exactly the way it is suppose to. It is not a bug, it is expected action.


I don't agree. There is no possible purpose this could be useful. Even so this behaviour has been annoying on at least 3 apps I've written that use the mouse for drawing.


MouseUp on Canvas from MS Forums. It inlcudes an explaination of why it happens and another way around it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Rattrap
MouseUp on Canvas from MS Forums. It inlcudes an explaination of why it happens and another way around it.


I didn't read any explaination or way around it. The last post is by the OP pasting in his onclick event with no solution. In his post before this he asks if it's "by design" and that it "can't be the desired behavior" and "is extremely problematic.".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!