How to check if PushButton is pressed ?
You know, there’s a number of great resources for beginners.
First, if you’re an absolute beginner to programming, there’s the textbook. It teaches you to program as well as use Xojo at the same time. Great two-in-one system.
There’s also a manual that comes with Xojo that teaches you the ins and outs of using the IDE, the language, and the features within. You can find that in the Documentation folder next to your installation of Xojo. There’s also an online reference http://documentation.xojo.com (you might find the documentation on PushButton quite useful)
Lastly, when you’re ready to learn from examples, there’s a folder full of example projects next to your Xojo install called “Example Projects” It helps when you don’t intend to reinvent the wheel. Do not copy and paste code from example projects, that won’t help you at all.
Thank you, i already follow “Introduction to programming with Xojo”, and i do read docs. I just like to experiment with code to see what will happen. It is my process of learning.
I was looking for a way to return the value of PushButton1. Action if it is possible
What type does it returns ?
[quote=336105:@Miljan Stojanovic]I was looking for a way to return the value of PushButton1. Action if it is possible
What type does it returns ?[/quote]
Store it ina Window or Module Property ?
The type ? Good question, but only you know the Type of the returned value: YOU return the value.
We cannot give you more information because only you know what the PushButton is meant to do, to return a value or not, whatever
At last, a value is stored in a variable, the variable can be of different kind, search for Variables for more data.
Usually, each and every book have a part (large or largest part of the book) about Variables, their Type (kind) and the max values they can hold (String, Text, Integer, Double, Float, etc.)
Edit:
“Introduction to programming with Xojo”
Did you open the provided code example shared with the book ?
In PushButton1. Action add Msgbox "PushButton1 was just pressed’
I was thinking something along the lines of :
If PushButton1.Action = True Then //True or some other type i am not sure that exists there
// Some code
End if
when the user pushes the button, the Action event is fired.
simple, you just have to add the code in the action event.
don’t need to check if it has been pressed, it already has if you come there.
you will have to check the values in the action of a popupmenu for example, but that’s another user interface.
[quote=336121:@Miljan Stojanovic]I was thinking something along the lines of :
If PushButton1.Action = True Then //True or some other type i am not sure that exists there
// Some code
End if[/quote]
I think the problem you are having is conceptual: that’s not how event driven programming works.
You push a button (an event) and the action event handler deals with what should happen.
While you are thinking the other way round.
But don’t worry - pretty much everyone did that at the beginning. Getting your head around object oriented programming is the real challenge.
[quote=336121:@Miljan Stojanovic]I was thinking something along the lines of :
If PushButton1.Action = True Then //True or some other type i am not sure that exists there
// Some code
End if[/quote]
I think there’s a conceptual problem here. If a pushbutton has been pressed, it has been pressed and the Action Event takes over, but the button does not STAY pressed once the mouse leaves it. If you are trying to determine if the button has been pressed at some time in the past, setting a flag in the Action Event is the way to go. If, however, you want to determine if the button has been and is still pressed even though the user is doing something else, you may be needing a toggle-capable button like the Bevelbutton, which does have the capability of remaining pressed and can return that state.
Yes… the difference is between
‘Has the button been clicked and I need to do something now’ (Action event)
or
‘Does the button appear to be pushed in’ (using a bevel button set to ‘toggle’) … in which case it’s
if button1.value then…