|
Corel Click &
Create
Tip 2 - To create a Button that will depress when the user
clicks it
To make your Click & Create applications look
more customized, you may want to add button objects that appear pressed in when the user clicks
them. The first step necessary to create this effect is to add the necessary objects to the playfield.
You will need to add an object to use as a button and a counter. For the purposes of this example,
we will use a button from the Click & Create libraries but if you want, you can create your
own button.
If you decide to create your own button in Click &
Create, you will need to draw an object or import a picture to use as an Active object. Buttons
must be Active objects in Click & Create. Once you have created the first button, you will
need to create a second Active object that differs from the first. This second object is displayed
when the button is clicked. You may want to add shadows and highlights or change the color of
the original button so the button looks different when clicked with the mouse. Once you have
created the second object, copy the object from the Picture Editor. Now paste the second button
object into the same animation sequence as the first button, but assign a different direction to the
second button. Therefore, if the first button uses the 0 direction, copy the second button into the
Picture Editor for the 16 direction.
To begin the procedure, add the necessary objects to the
playfield:
- In the Frame Editor, choose the Media: Widgets # 4
library from the library drop-down menu. Use button 1 or button 2 from this library. These two
buttons are 2-directional active objects that can be used as buttons. If you want you can also use
your own customized button object. Remember your object must have two different directional
views, one to represent when the button is not pressed and the other to represent when the button
is pressed. Place the button object on the playfield.
- Create a Hidden counter and place it on the playfield.
Now that you have added the necessary objects, we can
begin to set up the necessary events in the Event Editor. The first event will define the
appearance of the button at the start of the frame when it is not pressed by the mouse.
- In the Event Editor, click the New condition line at the
bottom of the event list.
- Double click the Storyboard controls icon and choose
Start of frame from the pop-up menu.
- Locate the intersection point of the first condition on the
left and the Button object icon on the top. Click this empty box with the right mouse button.
- Choose Direction, Select Direction from the pop-up
menu.
- Enable direction 0 (pointing directly to the right) and
disable any of the other directions. If you have used your own button object, select the direction
corresponding to the picture of how you want the button to look when it is not pressed by the
mouse.
- Click OK.
We have added the counter to this procedure to make the
button return to its original setting after a short period of time. Therefore, when the user clicks
the button it will be pressed in and then will automatically return to its original position after a
short delay. We must now define the settings for the counter:
- Click the New condition line and double click the Timer
icon.
- Choose Every from the pop-up menu.
- Set a short delay. This delay will tell Click &
Create how long to hold the button down when the user clicks the button. For this example, we
used 10 hundredths of a second for the delay. Click OK.
- Locate the intersection point of the second condition on
the left and the Counter object icon on the top. Click this empty box with the right mouse button.
- Choose Add to Counter from the pop-up menu.
- Type 1 in the Expression box.
- Click OK.
The above event means that every 1 hundredth of a
second, one will be added to the counter. Now, we will define the settings to change the
appearance of the button when it is clicked by the user.
- Click the New condition line and double click the
Mouse Pointer and Keyboard icon.
- Choose The Mouse, User clicks on an Object from the
pop-up menu.
- Define the type of mouse click that you want to test for.
The default values of left button and single click will work fine. Click OK to accept the settings.
- Click the Button object icon and click OK to accept the
object to test for a mouse click.
- Locate the intersection point of the third condition on
the left and the Button object icon on the top. Click this empty box with the right mouse button.
- Choose Direction, Select Direction from the pop-up
menu.
- Enable direction 16 (pointing directly to the left) and
disable any other directions.
- Click OK.
- Locate the intersection point of the third condition on
the left and the Counter object icon on the top. Click this empty box with the right mouse button.
- Choose Set Counter from the pop-up menu.
- Type 0 in the Expression box.
- Click OK.
This condition will test for a single, left mouse click on
the button. When the button is clicked the second picture of the button will be displayed and the
counter will be set to zero. There is one final event that must be defined. If you run the frame
now, the button will depress when the user clicks it but will not be reset. This final event will
reset the button back to its original state after being clicked by the mouse.
- Click the New condition line and double click the
Counter icon.
- Choose Compare the counter to a value.
- Enable the Equal radio button and type 2 in the
Expression box.
- Click OK to accept the type of comparison.
- Locate the intersection point of the fourth condition on
the left and the Button object icon on the top. Click this empty box with the right mouse button.
- Choose Direction, Select Direction from the pop-up
menu.
- Enable direction 0 (pointing directly to the right) and
disable any other directions.
- Click OK to accept the direction.
The above event will set the button back to the original
direction every time the counter equals two. Now when you run the frame, the button will appear
in the original state. When you click it with the mouse it will appear to be pressed in and will
automatically be reset back to its original state after a short delay.
![[Click here for
previous tip]](/deadend) ![[Click here
for next tip]](/deadend)
|
Click &
Create
|