Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I am creating an application in C# in visual Studio 2008 where in a single button will have 2 uses and it will depend on whether the user just presses the button or long presses the button.
 
i thought of adding a timer but it is a very clumsy way and i was thinking if there was an inbuilt way for this
Posted 20-Nov-12 5:47am
23nigam153
Comments
Sergey Alexandrovich Kryukov at 20-Nov-12 12:16pm
   
I answered, but in you need further detail, you need to tag you UI library you use.
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Easy. Except for button press, there are lower-level events, button down and then button up. You can detect the time between these events. Further detail depends on UI library you want to use and application type, but the code would be very similar.
 
[EDIT]
 
In most applications, I would not recommend you to operate on timing between down and up events, as the users are not used to it, this is not a common UI style. But sometimes we want to go out of common UI styles, then your idea might work for you. But even then, don't assume the user will get it if you don't care about explaining this unusual feature somehow.
 
—SA
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100