Hi, I am using WebImageViews for buttons in my web app. Code that gets actioned is put in the MouseUp event, as if it is in MouseDown and the user holds their mouse button down (or finger on an iPad) then the code gets executed multiple times. My problem is if the user double-clicks the control, the MouseUp fires twice and the code gets run twice.
I have tried to prevent the second MouseUp from running the action with code as below, but there is a timing issue and the webPage1.ButtonPressed boolean does not get set in time before the second MouseUp event fires. The app is running on a Centos server.
if not webPage1.ButtonPressed then
webPage1.ButtonPressed = True
// action code here
// allow buttons to be clicked again
webPage1.ButtonPressed = False
If anyone has any ideas how I can prevent the second MouseUp, or otherwise how I can resolve this, I’d be grateful to hear them!
Hi Michel, thanks for posting. It seems that DoubleClick does not fire. Sometimes, only one MouseUp fires and sometimes two. I can’t use MouseDown as if there user holds the mouse button down, the code fires multiple times.
Without changing too much of your code, you can use the same flag system to execute your code only once.
Set ClickOnce as public property and default value False
in MouseUp :
If ClickOnce = False then
//do your thing
ClickOnce = True
As it stands, the code will be executed once per session.
The tricky part is then to figure where to reset ClickOnce to False, so the customer can click again if needed. I do not know your app, so it is difficult to tell you where, but in essence, wherever the user is suppose to click afterwards, or when you change page, or whatever it is safe. You can also use a timer to reset ClickOnce after a set amount of time.