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.




13 comments:
Thank you very much for posting this hack. Double-click is highly important for the types of apps (web or not) that I develop.
Joe
Simple, Clean and effective.
Thank you very much.
... and it was my first link on the google!!! :-)
I needed that too! And thank you for keeping it simple.
Note: I hate gays, and I hope you do too (as well as other people on this thread).
um... so simple is good but there was nothing in the post about 'gays'...? we should stict to the topic of the post.
-David
It's a real shame that there are still people who are so irrational in this world. Please take your bigotry elsewhere.
this way you can't seperate single/double click.
That's probably the reason you were told.
sure you can seperate the click and double click. its a function of how fast the clicks are. the code show clearly how you have two blocks that handle the two cases.
what if the control I want to double click doesn't fire the MouseLeftButtonDown event?
another solution?
the same thing would apply to other events such as 'click' for a button etc.
Looking world of warcraft gold for and maplestory mesos and archlord gold wow goldarchlord gold or archlord power levelingSuch as world of warcraft Gold the Burning and buy archlord gold wow gold archlord power levelingand archlord goldand flyff moneyAfter being age of conan power leveling|*|wow power leveling|*|http://www.superpowerleveling.com|*|ghg525
Thanks for this tidbit, worked like a charm ;)
dessicant air dryer pediatric asthma asthma specialist
carpet cleaning dallas tx carpet cleaners dallas carpet cleaning dallas
beach vacations your beach vacations
bob hairstyle
bob haircuts bob layered pob hairstyle
bobbed classic bob Care for Curly Hair
Tips for Curly Hair curly hair 12r 22.5 best price
tires truck bus tires 12r 22.5 washington new house
new house Houston new house san Antonio new house ventura
sealy air beds portable portables air beds
antique doorknobs drying desiccant
air drying desiccantlipitor allergic reactionsApple prodam iphone praha
new houston house houston house tx stains removal dye
stains removal clothes stains removal teeth whitening
teeth whiteningbright teeth jennifer grey nose
jennifer nose jobs calebrities nose jobs Women with Big Noses
Women hairstyles Big Nose Women, hairstylesdvd player troubleshootingtroubleshooting with the dvd playercheap beach vacationsnight vision binoculars bargainsflorida headache clinic
Post a Comment