Page 1 of 1

How Do I Make a Simple Button Show a Message?

Posted: Tue May 27, 2025 10:05 am
by vidor636
I'm completely new to LiveCode and just started exploring it after seeing how beginner-friendly it claims to be. I'm following some tutorials, but I wanted to try something on my own to understand the basics better.

Right now, I'm trying to create a super simple app where I press a button, and it shows a message like "Hello, world!" in a popup. I added a button to my card, but I'm not sure where or how to write the code to make the message appear.

Could someone please walk me through:
  1. Where exactly do I write the script?
  2. What is the correct code to show a basic popup message?
  3. Any tips on how to test and make sure it's working?
Thanks so much in advance! Looking forward to learning more and building small projects as I go.

Re: How Do I Make a Simple Button Show a Message?

Posted: Tue May 27, 2025 10:24 am
by Klaus
Hi Vidor,

by switching the TOOL in the "tools" palette, see screenshot, you can easily switch between RUNTIME and EDIT "mode".
Using the left tool (the runtime tool) you can test your stack like an enduser of your (later) app will experience it.

With the right tool (the EDIT tool), the arrow with the little cross, you can add new controls (buttons, fields etc.) and also write scripts
for all of your objects on the card:
Bildschirmfoto 2025-05-27 um 11.10.35.png
Bildschirmfoto 2025-05-27 um 11.10.35.png (7.99 KiB) Viewed 2915 times
Do this:
Click the EDIT tool in the palette, then RIGHT-CLICK on your button and select "Edit script" in the popup-menu:
Bildschirmfoto 2025-05-27 um 11.11.14.png
Bildschirmfoto 2025-05-27 um 11.11.14.png (17.55 KiB) Viewed 2915 times
Then the SCRIPT WINDOW will appear and you can write your script.
See a list of available hanlder for this object in the list on the left.
Click on "mouseup" and the so far empty handler will appear on the right side in the window.
Now add this:

Code: Select all

on mouseup pMouseButton
   ## This marks a comment, so you can add comments to your script 
   ## to know later what you have been doing here :-)
   
   ## The following line is the actual script that will open a dialog window with your string and an OK button
   answer "Hello Vidor!"
end mouseup
This will open a new window, a modal dialog, where you need to click on "OK" to make it diappear again.
Congrats you wrote your first working script. :-)

Here you can find more infos and tutorials:
https://lessons.livecode.com

Best from germany

Klaus

Re: How Do I Make a Simple Button Show a Message?

Posted: Tue May 27, 2025 2:57 pm
by dunbarx
Hi.

Everything Klaus said.

But did you really mean "in a popup"? Klaus' handler will show a modal dialog. Another, similar possibility is to pull a new field from the tools palette, just like you did for that button. Then you could say, in that handler,

Code: Select all

put "Hello World" into field 1
And yet another way is to already have such a field, but which is currently hidden. Then you could:

Code: Select all

show field 1
I am merely introducing a few simple idea for you to think about and play with.

But those still are not a"popup". Are you sure you are using that term correctly?

Craig

Re: How Do I Make a Simple Button Show a Message?

Posted: Tue May 27, 2025 9:20 pm
by richmond62
I looked up 'Display "Hello World" in a popup' and got a plethora of possibles of which the one that came up the most was a modal dialogue window.

Re: How Do I Make a Simple Button Show a Message?

Posted: Tue May 27, 2025 9:33 pm
by richmond62
If you are working with MacOS you can display a substack as a sheet:
-
Screenshot 2025-05-27 at 23.31.11.png
-
Screenshot 2025-05-27 at 23.31.19.png