Changing picture when button is pressed

Hello, at this moment i have a button at the middle of the screen. Then a picture of a sea and a another picture on top of the picture of the which is a green bush. The button says, press to change picture. What i want to do is i want the picture to switch when from sea to green bush when that button is pressed. It will be great if you could give me the code for this as well. And tell me what to do step by step. I am still a beginner so please do not be annoyed by my amateur questions. :)))

Tell you what… lets make this a learning experience.

  1. post what you have done
  2. post what you have tried that has failed
  3. we will help you by pointing out what went wrong

But since we don’t know what you have, what you did, what you tried, we can’t tell you what to change.


This is what i have done so far. All i did was added a photo, in fact 2 photos on top of eachother then placed a button at the button middle. The button says press the button is change photo. In the button action what would the code be to change the button.

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

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.

Once you’ve learned up, if you still have questions we’re happy to help here. But as Dave said, we need to know what you’ve tried, how it went wrong, and what you really want to happen. I’ve seen a number of threads where we haven’t been able to help someone because they were trying to obfuscate what they were really doing for some reason.

Best of luck to you :slight_smile:

All i want to do is change a picture from one to a another when a button is pressed I just want the code for that :)))

If you want someone to write code for you, you can also hire a consultant

It all depends on how the original picture got there…
whining isn’t helping you… this forum is designed to help developers help them selves… its not to write code (or do your homework for you)… how do you learn anything that way?

Is it me or are more and more newbies wanting to be experts but not willing to do the research, ask pointed questions… and learn? perhaps I’m becoming that grumpy old man… but “entitlement” never was in my vocabulary.
I learned my trade beginning when there were no online resources, and went to the school of hard-knocks… and continue teaching myself new things, and broadening my horizons every single day.

Did you add a MouseDown Event to your PushButton ?

If no, do that and place there the code to load the other picture…

Here are some relevant topics in the User Guide that have examples that might be helpful:

[quote=329841:@Anamu Uenishi]file:///Users/Hoippy/Desktop/Screen%20Shot%202017-05-08%20at%2017.57.27.png

Anamu, to post pictures on the forum, this is not how it works.

Post your picture on, and then post the URL of each picture in the forum.

How did you come up with the program you describe in your first post ? Have you already tried to do it with Xojo ? What have you built so far ?

@Anamu Uenishi
Here’s a hint. First of all, don’t try to put a picture on top of a picture. Create a single canvas and show the picture you want inside that canvas’s paint event.
There are a wealth of good example apps which come with the Xojo download. Take those and study them until you know what every line of code does. Good luck.