Button Down State

  • Thread starter Thread starter shahoo
  • Start date Start date
S

shahoo

Hi,
I want to simulate the two buttons in a scroll bar, i.e, use two
buttons and when the user clicks on them and holds the button, I
should scroll. My problem is when the button is clicked, It scrolls
once not for the time the button is down.
Can anyone help me with that please?
 
shahoo said:
Hi,
I want to simulate the two buttons in a scroll bar, i.e, use two
buttons and when the user clicks on them and holds the button, I
should scroll. My problem is when the button is clicked, It scrolls
once not for the time the button is down.
Can anyone help me with that please?

You will want to use a timer of some sort. Whenever the button goes
into the pushed state, start the timer and let it repeat as long as the
button remains in the pushed state.

For bonus points, update the timer's interval according to how long the
button's been pushed. At a minimum, start with a longer interval and
then change the timer's interval to be shorter once the first interval
expires. To be even fancier, have the timer start out long and then
gradually shorten the longer the button is kept pushed. If you want to
go completely crazy :), once the timer interval reaches some practical
minimum (depends on how long updates take, what timer you're using, etc.
but 50-100 milliseconds might be an appropriate minimum), increase the
total scroll distance rather than the timer interval.

Pete
 
shahoo said:
Hi,
I want to simulate the two buttons in a scroll bar, i.e, use two
buttons and when the user clicks on them and holds the button, I
should scroll. My problem is when the button is clicked, It scrolls
once not for the time the button is down.
Can anyone help me with that please?

Nishant Sivakumar has ported an AutoRepeat Button class to .NET. You might
want to refer to his implementation at
http://www.codeproject.com/cs/miscctrl/csautorepeatbutton.asp.

Best Regards,
Stanimir Stoyanov
www.stoyanoff.info | www.aeroxp.org
 
You will want to use a timer of some sort. Whenever the button goes
into the pushed state, start the timer and let it repeat as long as the
button remains in the pushed state.

For bonus points, update the timer's interval according to how long the
button's been pushed. At a minimum, start with a longer interval and
then change the timer's interval to be shorter once the first interval
expires. To be even fancier, have the timer start out long and then
gradually shorten the longer the button is kept pushed. If you want to
go completely crazy :), once the timer interval reaches some practical
minimum (depends on how long updates take, what timer you're using, etc.
but 50-100 milliseconds might be an appropriate minimum), increase the
total scroll distance rather than the timer interval.

Pete

Thanks so much, It worked perfectly !!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top