Anyway, recently, I was told that you can't double-click in Silverlight...
So to me this is a bit hard to respond too. Not because Silverlight doesn't support it, but because if it supports single click or, 'OnMouseDown' -- 'OnMouseUp' or anything similar, then we are good. Basic computer science 101 stuff, right? All you need to do is something like this example.
In my code I create a counter for counting ticks. Say like this in c#:
public long LastTicks = 0;
Then in my 'MouseLeftButtonDown' event I have an 'if' statement that basically checks to see if the number of ticks between the last two mouse clicks is less then some defined number like this:
if ((DateTime.Now.Ticks - LastTicks) < 2310000)
{
// double click
here...
}
...and then at the end of the method, we have a line that sets the LastTicks value like this:
LastTicks = DateTime.Now.Ticks;
Nice and simple. This gives us a good solid double-click that we can do with whatever we need. Now in this sample we are using ticks but we could use any date-comparision thing and use seconds, for example, and we would just have to calculate the differential we want to use. For me it was 23.1 million ticks which seemed to work good on my box :)
Now don't go sending me a billion emails on why we don’t use double clicks in web apps. I'm just saying that it can be done, and a number of people asked. I know very well that double-click is not a good plan generally in a web sort of paradigm.
0 comments:
Post a Comment