Creating a Toolbar Button
Import The Toolbar Icon
Start by importing the image you will use for the toolbar icon into a stack.
I've imported a PNG image.
Create a Button
Now create a rectangle button by dragging it from the toolbar to the stack.
Configure Button Properties
Open the Property Inspector for the button you just created. First set the style of the button to "Transparent Button".
Now set the label of the button to the text you would like to appear under the icon.
Now switch to the "Icons & Borders" property pane.
1) Set the icon of the button to the id of the image you imported in step 1. The id is listed in the "Basic Properties" pane of the Property Inspector when you select the image.
2) Uncheck the Three D checkbox.
3) Set the Border width to 0.
4) Now resize the button so that the text and icon are visible.
Hide The Image
You can now hide the image you imported. With the image selected, uncheck the "Visible" checkbox.
Comments (2)
Bruce January 25, 2008 10:37
so does this mean that the image that's been imported must remain on the stack even though its invisible to use this technique?
Trevor DeVore January 31, 2008 17:00
You don't have to leave the image on the stack but if you decide to move the image to another stack you need to understand how Revolution finds an image based on id.
From the "icon" entry in the docs:
"Revolution looks for the specified image first in the current stack, then in other open stacks."
Let's look at the example from this lesson. When drawing the button icon Revolution is going to search for an image with an id of 1003. If the stack that the button is in does not have an image with an id of 1003 then Revolution begins looking in other stacks. The first image with a matching id that Revolution finds will be displayed.
Now 1003 is a pretty common id in a stack so it is very possible that an image other than the one you were expecting could be displayed. In order to ensure that the right image is displayed you will want to assign an id to the image that will be unique among all open stacks. When placing images in a stack other than the one the button is on I usually start with an id of 50000 and work up from there.
Add your comment