I'd like to display an image which acts as a button. This means that when I click on the image a mouseUp
handler is executed.
- image area does not have a
mouseUp
handler - the buttons seem not to have a property where I can assign an image to them.
I'd like to display an image which acts as a button. This means that when I click on the image a mouseUp
handler is executed.
mouseUp
handlerYou can add a mouseUp handler to an image's script, and it will be triggered when the image is clicked:
on mousedown
answer "hi"
end mousedown
You can give a button an image by setting it's "icon" property to the id of an image on the stack (you will generally then want to unset the 'opaque', 'threed', and 'shadow' properties in order to make it look pretty).
What David said.
Though "mouseUp" is introduced as a natural button-related handler, be aware that any object can have such a thing, including a field if it is locked, and there are even ways around an unlocked field as well. The important thing is to know that the language and its environment are far broader and richer than you might at first infer from the tutorials and lessons.
Craig Newman
You can assign icons to buttons. This solves all your problems at once.
Create a new image control, e.g. by importing an image using the File menu. Create a new button and set the icon of the button to the id of the image control. If you like, you can use another image control for the hilitedIcon of the button. Add mouseUp and mouseDown handlers to the button as desired.
If the image is too big, resize the button to make the image fit. Set the showName of the button to false or change the margins (something like 0,32,0,8) to move the text below the icon.