Notifications
Clear all

[Closed] ImgTag click fires several times

Hi, I’m currently building a small tool to aid in putting together locations, and have run into a little problem.

I use a collection of dynamically generated imgTags with a click handler, and I have an issue when the click handler is fired, and waiting for the merged file to finish loading, if the user clicks anywhere at all before the loading is done, the click handler for the imgTag will fire again, trying to load the asset a second time. Is this a known issue? A case of misusing the click handler? I can’t easily make a piece of code that reconstructs the issue ( :argh: ), but I’m hoping someone else knows this issue and/or has some help to offer.

Thanks!

Mikkel

3 Replies

Hi Mikkel,
Well, this is not exact an issue, its come to you if and how to protect any control from unwanted user activity.
The ImgTag offer many events, here is some possible workaround using boolean flag stored in variable named IsBusy:

on myControl myEvent [args_if_any] do
(
	if not IsBusy do -- wrap the event
	(
		IsBusy = true -- change the flag
		setWaitCursor() -- Optional (for user feedback)
		-- Main procedure here...
		setArrowCursor() -- restore the cursor
		IsBusy = false -- change the flag
	)
)

another way is to disable the control on time of the called function works, and enable the control after the function finished.

1 Reply
(@panayot)
Joined: 11 months ago

Posts: 0

yeah, thats an alternative, so it improve the reply,
i skip to mention it as not looks so flexible to me,
and some notes about w’d be welcome as well, i hope.

this approach is fine but just in one case –
when the control is enabled by default and
there no any external event that affect it #enable state.

in other words, abandoning this method (for that purpose)
will simplify your future code maintenance,
or at least i think so.