locked
auto repetition on mouse events RRS feed

  • Question

  • Hi all.
    I have added a few buttons that allow page-up/down line-up/down on some text shown in a textbox (for mouse users).
    I'm trying to allow auto repetition on mouse down click (if the mouse is not release i would like a re-firing of the mouse event or any other event).
    I know i can use the clock & check if the mouse was released every X sec... but there must be an event for such thing in WPF.
    I have checked a couple of books and surf the net but couldn't find anything helpfull so if any of you guys know about such a thing
    it will be most helpfull :)
    Sunday, April 5, 2009 5:42 PM

Answers

  • Use the RepeatButton control.  It has the behavior you are looking for.

    <Grid>
    
        <RepeatButton Interval='300'
    
                      Delay='500'
    
                      Content='Repeat Button'
    
                      Click='RepeatButton_Click' />
    
      </Grid>
    
    
    Then use the Click event procedure.

    C#

    private void RepeatButton_Click(object sender, RoutedEventArgs e) {
    
      this.Title +=".";
    
    }
    
    
    VB

    Private Sub RepeatButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
      Me.Title &= "."
    End Sub
    

    Walt | http://wpfwonderland.wordpress.com
    • Proposed as answer by Walt Ritscher Monday, April 6, 2009 1:09 AM
    • Marked as answer by Tal Weiss Monday, April 6, 2009 2:43 PM
    Sunday, April 5, 2009 6:34 PM

All replies

  • Use the RepeatButton control.  It has the behavior you are looking for.

    <Grid>
    
        <RepeatButton Interval='300'
    
                      Delay='500'
    
                      Content='Repeat Button'
    
                      Click='RepeatButton_Click' />
    
      </Grid>
    
    
    Then use the Click event procedure.

    C#

    private void RepeatButton_Click(object sender, RoutedEventArgs e) {
    
      this.Title +=".";
    
    }
    
    
    VB

    Private Sub RepeatButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
      Me.Title &= "."
    End Sub
    

    Walt | http://wpfwonderland.wordpress.com
    • Proposed as answer by Walt Ritscher Monday, April 6, 2009 1:09 AM
    • Marked as answer by Tal Weiss Monday, April 6, 2009 2:43 PM
    Sunday, April 5, 2009 6:34 PM
  • Thank you very much 
    Sunday, April 5, 2009 9:27 PM
  • Hi.

    how do i use RepeatButton when the event handler of click causes the

    Focus to be on a diffrent GUI component (RichTextBox that needs the focus in order to move the cursor...)?


    Monday, April 6, 2009 11:37 AM