-
November 17th, 2015, 07:49 AM
#1
Action while a button is pressed
I'm trying to do a repeat action while a button is pressed.
Private void button1>Clicked(object sender EventArg e)
{
while ( "Mouse Left Button Down")
{
"Print X"
}
"Print T"
}
I'm not sure how to check if the Mouse button is pressed.
-
November 17th, 2015, 11:56 AM
#2
Re: Action while a button is pressed
Look at the MouseDown and MouseUp events.
-
November 17th, 2015, 02:29 PM
#3
Re: Action while a button is pressed
Thanks for the suggestion. I did a little more reading and came up with the following.
I added the 2 event definitions?
button1.MouseDown += new MouseEventHandler(button1_MouseDown);
button1.MouseUp += new MouseEventHandler(button1_MouseUp);
Then I was able to use
private void button1_MouseDown(object sender, EventArgs e)
{
"Print X"
}
private void button1_MouseUp(object sender, EventArgs e)
{
"Print T"
}
This accomplished what I was trying to do.
Thanks for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|