|
-
Nov 15th, 2010, 05:06 AM
#1
Thread Starter
Addicted Member
is setting a boolean the only way to detect if a button has been clicked?
Hi all.
I have written a calculator program, and when the mouse clicks on the equals button, the button sets a boolean varaible to true, and then that variable can be used later.
But I am wondering if the button control has it's own property that can indicate if it has been pressed?
Thanks in advance.
-
Nov 15th, 2010, 08:56 AM
#2
Re: is setting a boolean the only way to detect if a button has been clicked?
Event driven programming doesn't work that way, you never need to check a button to see if it was clicked or not, instead you handle it's click event so when it does get clicked it runs that code.
For example, when the equals button is clicked you should complete the math operation (IE do the addition or subtraction, etc) & store that in the variable as well as show the result to the user. Then when they click another button if it's an operation (addition, subtraction, etc) you already have the result stored so it should be no different than if they clicked a number button first.
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
|