disabled WebListBox responds to a double click

I have a WebListbox that on double click sends an HTTP request to a database server. I need to be sure that the user does not initiate a second request with a double click while the method sending the request is waiting for a response. To accomplish this I am disiabling the list box prior to sending the request. It appears that this does not keep the listbox from responding to a double click while it is disabled. So after the initial requesting method finishes and the list box is enabled, the second double click executes.

To get around this I tried using a global variable that when set to true the listbox code for the double click is skipped over. I am having a heck of a time trying to get the timing right for this hack. The execution of the code is run in a timer otherwise the disabling of the list box will not take affect until after the requsting code runs, defeating the whole purpost of disabling the list box. Resetting the global tp false at the end of the timer code does not work, I think because the second double click appears to be executing before the gobal actually resets to false.

Any ideas, or is there something I am missing.

Mouse events are asynchronous, have a look here for some workarounds.

Yes the fact that they are asynchornous is the problem.

With the list box disabled a double click is generated and the DoubleClick event code runs as soon as the method executing when the unwanted double click occurs finishes. I am trying to stop that second double click from running the DoubleClick event code…

Double Click Event code…

[code]if cbSendURLLink.Value then
ProgressWheel1.HorizontalCenter = cnt_emailURLs1.HorizontalCenter
ProgressWheel1.VerticalCenter = cnt_emailURLs1.VerticalCenter

FolderChangeInProgress = true
enableDisableControls(false) //disables the list box among other controls
timer1.Mode = Timer.ModeSingle
//need to use a timer to show the Progress Wheel and disable the list box and other controls
//while the timer code is running the http request.
end if[/code]

Timer code…

[code]me.Mode = timer.ModeOff

//Code to initialize everything for the http request
//during all this time all the controls I do not want usable are disabled

DIM data As string = socket1.Post(“http://”+Host+"/chaos/UploadToAWSOnly?output=xml&site=xojo", 45)
data = defineEncoding(data, encodings.UTF8)

//Code to digest the returned data

enableDisableControls(true) //listbox along with other controls get enabled

//At this point if the user had indavetantly double clicked the list box while the timer code was runing, the On Double Click event unnecessarily runs again. In fact it doesn’t matter if the list box is disabled or enabled, the On Double Click event code runs.[/code]

The problem is that if the user double clicks a row in the listbox while it is disabled, the Double Click sends another http request as soon as the timer code finishes. Usally the unwanted double click is a mistake by the user or a user not thinking that they in fact double clicked a row. In any case, the unwanted double click creates a miriad of problems in both the running WebApp and the database back end.

I have to figure out how to keep the code in the On DoubleClick event of the list box from running when an uwanted double click occurs while the list box is disabled. I tried using a varible that is set to true if double clicks are not allowed but I can’t get it set before the unwanted double click event is executed.

First off in my prior post I messed up the double click code. I did not include the test to see if the listbox was enabled. It should have read like this…

Double click code…

[code]if cbSendURLLink.Value And lb_documents.enabled then
ProgressWheel1.HorizontalCenter = cnt_emailURLs1.HorizontalCenter
timer1.Mode = Timer.ModeSingle

end if[/code]

Tha being said, not much advice received, but I did figure out how to make the timer work.

I had earlier tried putting the 2 enabling methods into a second timer, but could not get it to work. This time around I realized that the problem was that the period for the second timer was too short so the unwanted double click was actually running after I had enabled the listbox. I had it set to 1 so it would execute immediately thinking I had to beat the unwanted double click code running. It turned out to be the other way around.

So, at the end of the first timer it calls the enabling timer like this…

First timer

EnableControls_Timer.Period = 1000 //I could have made this the default for the timer EnableControls_Timer.Mode = timer.ModeSingle

The EnableControls_Timer executes the 2 enabling methods previously called in the firs timer and looks like this…

Second enabling timer…

cnt_emailURLs1.enableDisableControls(true) enableDisableControls(true) //listbox along with other controls get enabled

The key was to give the unwanted double clicks time to run the double click code while the list box was disabled, which the double click code skips if the listbox is disabled. I think I had the root of the timing problem wrong.

I hope this helps someone else struggling with this dilemma. I really think it a poor design to allow a disabled control’s code to run when it is clicked or double-clicked. I know that clicks are asynchronous, but there must be a way for xojo to disable or skip the code of a disable control. What good then does it do to disable a control except for the visual effect?