Handling Click and DoubleClick events differently
-
I have an application that I'm converting to C# and have run into a problem. If I overlooked the discussion of this elsewhere, I apologize in advance. Here's the situation: I have a list box with various items in it. When I click on one, I want it to select the item and highlight the equivalent info on another control - that works perfectly. When I doubleclick, I want it to open a dialog allowing the item to be edited, displayed in detail or something similar. Unfortunately, even though both events are active and coded, the single click event always fires, no matter how fast one doubleclicks. In order to get the double click to work, I have to click 3 times and the single click event always fires first. I know one option would be to change the UI, but this is a mature (but non.NET) application and users want the same click vs. double click performance, so changing the behavior is a last resort and not really a good option. Is there something I'm doing wrong? Is there a workaround? BTW, the equivalent code works perfectly in the old app, which was written in Delphi. Any suggestions or insights would be very much appreciated!
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
-
I have an application that I'm converting to C# and have run into a problem. If I overlooked the discussion of this elsewhere, I apologize in advance. Here's the situation: I have a list box with various items in it. When I click on one, I want it to select the item and highlight the equivalent info on another control - that works perfectly. When I doubleclick, I want it to open a dialog allowing the item to be edited, displayed in detail or something similar. Unfortunately, even though both events are active and coded, the single click event always fires, no matter how fast one doubleclicks. In order to get the double click to work, I have to click 3 times and the single click event always fires first. I know one option would be to change the UI, but this is a mature (but non.NET) application and users want the same click vs. double click performance, so changing the behavior is a last resort and not really a good option. Is there something I'm doing wrong? Is there a workaround? BTW, the equivalent code works perfectly in the old app, which was written in Delphi. Any suggestions or insights would be very much appreciated!
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
I remember reading a while back that a double click action should always be an 'add on' to a single click. Eg: In Explorer, single click selects a folder/file; double click selects it and then opens it. I suppose you could spin off a thread in your single click handler that waits to see if a double click event is fired, and if not, does its work. I am almost certain that would turn out to be very ugly. Long story short - if your double click action differs significantly, it's better off as a right click option.
Cheers, Vikram.
The hands that help are holier than the lips that pray.
-
I have an application that I'm converting to C# and have run into a problem. If I overlooked the discussion of this elsewhere, I apologize in advance. Here's the situation: I have a list box with various items in it. When I click on one, I want it to select the item and highlight the equivalent info on another control - that works perfectly. When I doubleclick, I want it to open a dialog allowing the item to be edited, displayed in detail or something similar. Unfortunately, even though both events are active and coded, the single click event always fires, no matter how fast one doubleclicks. In order to get the double click to work, I have to click 3 times and the single click event always fires first. I know one option would be to change the UI, but this is a mature (but non.NET) application and users want the same click vs. double click performance, so changing the behavior is a last resort and not really a good option. Is there something I'm doing wrong? Is there a workaround? BTW, the equivalent code works perfectly in the old app, which was written in Delphi. Any suggestions or insights would be very much appreciated!
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
Assalam-0-Alaikum Are you willing to do it on ClientSide or ServerSide? Regards. Atif Ali Bhatti.
-
Assalam-0-Alaikum Are you willing to do it on ClientSide or ServerSide? Regards. Atif Ali Bhatti.
Alaikum Assalam. He is talking about a Winforms app.
Cheers, Vikram.
The hands that help are holier than the lips that pray.
-
Alaikum Assalam. He is talking about a Winforms app.
Cheers, Vikram.
The hands that help are holier than the lips that pray.
OK. Following links can help u out. This one is Excellent and easy, http://msdn.microsoft.com/en-us/library/ms171543(VS.80).aspx[^] this one is also good. http://www.megasolutions.net/cSharp/Click-vs-DoubleClick-44615.aspx[^] Hope this solves your problem. Regards. Atif Ali Bhatti.
-
Assalam-0-Alaikum Are you willing to do it on ClientSide or ServerSide? Regards. Atif Ali Bhatti.
Actually it's a desktop app, no client or server involved.
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
-
I remember reading a while back that a double click action should always be an 'add on' to a single click. Eg: In Explorer, single click selects a folder/file; double click selects it and then opens it. I suppose you could spin off a thread in your single click handler that waits to see if a double click event is fired, and if not, does its work. I am almost certain that would turn out to be very ugly. Long story short - if your double click action differs significantly, it's better off as a right click option.
Cheers, Vikram.
The hands that help are holier than the lips that pray.
Vikram A Punathambekar wrote:
I remember reading a while back that a double click action should always be an 'add on' to a single click. Eg: In Explorer, single click selects a folder/file; double click selects it and then opens it.
Actually the program pretty much does that. The single click selects the item on the list and changes it's color on the adjacent map, show that it is selected. The double click effectively displays details of the selected item. That's exactly what the MS documentations say should be done. Actually I don't mind if the Click event fires. The problem is having to more than double click to get the DoubleClick event to fire.
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
-
OK. Following links can help u out. This one is Excellent and easy, http://msdn.microsoft.com/en-us/library/ms171543(VS.80).aspx[^] this one is also good. http://www.megasolutions.net/cSharp/Click-vs-DoubleClick-44615.aspx[^] Hope this solves your problem. Regards. Atif Ali Bhatti.
Thanks! I'll take a look. This works fine in other systems, so there has to be a solution.
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
-
Thanks! I'll take a look. This works fine in other systems, so there has to be a solution.
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
Well, I looked at the links you provided and realized I had already checked them before posting my original question here. However, I also have done some more troubleshooting - and still have no idea what I'm doing wrong. I now removed the MouseClick event totally and replaced it's behavior with the SelectionChanged event. I still don't get the MouseDoubleClick event firing until the 3rd mouse click. I even removed the SelectionChanged event - same thing - it takes 3 clicks to get the MouseDoubleClick event. I guess I still have some more playing around to do. My random thought is that maybe the MouseMove event or something else is interfering, but I wouldn't have expected that at all. Is it possible that the list control doesn't have focus and it takes an extra click to get focus, then start with the double click? As you can probably tell, I'm grasping now. Thanks for the links and at least it got me thinking along a different line.
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
-
Well, I looked at the links you provided and realized I had already checked them before posting my original question here. However, I also have done some more troubleshooting - and still have no idea what I'm doing wrong. I now removed the MouseClick event totally and replaced it's behavior with the SelectionChanged event. I still don't get the MouseDoubleClick event firing until the 3rd mouse click. I even removed the SelectionChanged event - same thing - it takes 3 clicks to get the MouseDoubleClick event. I guess I still have some more playing around to do. My random thought is that maybe the MouseMove event or something else is interfering, but I wouldn't have expected that at all. Is it possible that the list control doesn't have focus and it takes an extra click to get focus, then start with the double click? As you can probably tell, I'm grasping now. Thanks for the links and at least it got me thinking along a different line.
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software
Assalam-0-Alaikum, Well why the MouseDoubleClick event is taking 3 clicks to fire is due to the fact that you have to rollback the activity performed during the first click.. this is very important point to keep in mind. after rolling back the first click event activities, you are supposed to handle the double click event. Hope you get my point. Regards. Atif Ali Bhatti.
-
Assalam-0-Alaikum, Well why the MouseDoubleClick event is taking 3 clicks to fire is due to the fact that you have to rollback the activity performed during the first click.. this is very important point to keep in mind. after rolling back the first click event activities, you are supposed to handle the double click event. Hope you get my point. Regards. Atif Ali Bhatti.
Maybe I'm just dense, but I don't get the point. As I mentioned in another post in this thread, I've disabled the MouseClick event. It doesn't have a delegate, it doesn't do anything, the event handler has been deleted. There doesn't seem to be anything to roll back. The only mouse event I have active with a handler is MouseDoubleClick. And it still takes 3 mouse clicks to get it to fire. Obviously I'm missing something or .....
The PetroNerd
Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software