How to close a button

How do you close a button in a user interface with the close button I have a button where when you click on it it starts displaying text but when you click the x button it continues to display text how do I get it to stop

Hi Blake,

do you think you could use punctuation when you describe your problem? Please show your code and then describe in detail what problem you are trying to solve.

Sounds like your button is monopolizing the UI, so your app can’t respond to the close button. Put your code in a Thread to keep the UI responsive. A long loop in a button Action event is a bad idea.

ok MsgBox “It works!”
when you click the click me button it displays the it works message and no matter what you click you have to click yay

That is how it should work. A MsgBox does not disappear until you click OK.

What did you expect ?

If you display the Cancel button, I believe you can dismiss the MsgBox with Esc.

i can understand that but i want to know how to get it to close when you push close

Get what to close?
By clicking the X on Windows you’re just closing that one MsgBox. The code is run sequentially, so the next MsgBox will always appear regardless of how you closed the first one (by button or close box on Windows)

Have you checked out the Introduction to Programming Textbook?

It will get you started with Xojo and programming in general. From there there’s a whole manual to read in your Xojo install within the folder titled Documentation.

oh ok thanks but what i mean is how to to stop all the message boxes form running thru if you close one

What do you want to achieve, exactly ?

MsgBox “It works!”
when i run this program i want to it be able to click on close in it works and not have it take me to yay they way to works right now no matter what i click i have to go to yay and then it will close but i want to be able to click it works and not have to go to yay

Then don’t use MsgBox, but instead MessageDialog, which returns a result :

That way you can check what the user did in "It works! ", to see if you can continue or quit the button Action event with Return.

well see i thought of that too but i cant figure out how to program it to where to doesn’t make more buttons now what i want it to do is when a person wants to close the whole program and not be forced to go to the next message box they can just click on the x and it will shut down the whole program taking them back to the click me button

or do you mean there’s a way to get it where when you click on click me it loads the dialogue and keeps playing as long as you click on ok but when you click on close it will close it out without have to make more buttons

Using several MsgBox in a row is a bad design anyway.

MsgBox are usually used only for warnings.

It may be time for you to explore other possibilities, such as displaying a message in a label.

Without any idea about what you want to do, I cannot help more.

its fine and i don’t mind looking into other possibility’s but what i want is for when you click on the x in it works to not go to yay right after for it to close out the program

You don’t understand. A MsgBox is modal, meaning you cannot do anything besides clicking OK (or Cancel if you enabled it). No, you cannot click the red x when a MsgBox is displayed.

Asking over and over won’t make it possible. Maybe you should learn a bit more about programming, and come back when you are familiar with user interface design.

There is much, much more than MsgBox.

its fine thanks ill look into other things bye