|
Corel Click &
Create
Tip 5 - Dragging and Dropping in Click
& Create
Basic Dragging and Dropping
The ability to drag and drop objects isn't automatically built
in to Click & Create; however, you can imitate drag and drop functionality. It is possible to
drag and drop Active objects only. The drag-and-drop functionality we're going to create allows
the user to double-click an active object; drag that object to a new location and then single click
the mouse to release the object in its new location. Imitating dragging and dropping requires
three Event editor entries for each object you want to be able to drag.
To demonstrate this principle, you need to place the
following objects on the Frame Editor playfield: a counter object and at least one active
object.
In the Event Editor set an event to have the mouse
pointer pick up the object.
- Click the New condition box and double click the
Mouse pointer and keyboard icon.
- Choose The mouse, User clicks on an object from the
pop-up menu.
- In the Mouse click dialog box, enable the Left button
and Double click radio buttons.
- Click OK to accept the type of click.
- Double click the Active object icon. A new condition
will appear in the Event Editor list that states "User double-clicks with left button on
Active object 1".
- Find the empty grid box that corresponds to the new
condition and is under the Counter icon. Click this grid box with the right mouse button.
- Choose Set counter from the pop-up menu.
- Type 1 in the Enter expression box.
- Click OK. An action marker will appear in the grid box
to show that the action "Set counter to 1" has been set.
If you had placed two Active objects on the playfield,
you want to create a condition "User double-clicks with left button on Active object
2" with an action under the Counter icon that specifies "Set Counter to 2".
Create a new condition for each of the active objects on your playfield. The counter acts as a
condition flag. Depending on which object the user double clicks on, the counter is set to a
different number. For example, set the counter to 3, if the user double clicks on Active object 3.
You now have an event that detects when a user has
double-clicked on Active object 1. When the user double clicks the object, you want Active
object 1 to follow the mouse. To have the object follow the mouse, set the following event:
- Click the New condition box and double click the
Counter icon.
- Choose Compare the counter to a value from the pop-up
menu.
- Enable the Equal radio button and type 1 in the Choose
expression to compare with box.
- Click OK. A new condition will appear in the Event
Editor list that states "Counter =1".
- Find the empty grid box that corresponds to the new
condition and is under the Active object 1 icon. Click this grid box with the right mouse button.
- Choose Position, Set X coordinate from the pop-up
menu.
- Click the Edit button and click Retrieve data from an
object.
- Choose Current X position of the mouse from the
pop-up menu.
- Click the same grid box again with the right mouse
button.
- Choose Position, Set Y coordinate from the pop-up
menu.
- Click the Edit button and click Retrieve data from an
object.
- Double click the Mouse pointer and keyboard icon.
- Choose Current Y position of the mouse from the
pop-up menu.
- Click OK to accept the function. An action marker will
appear in the grid box to show that the action "Set Y position to YMouse" has been
set.
If you have more than one active object on the screen,
you will have to set similar conditions for each object. If you run your application now, you will
see that you can double click and drag the active object around the screen, but you can't drop it.
Therefore, the final condition must allow the user to drop the active object into a new position.
To drop the active object:
- Click the New condition box and double click the
Mouse pointer and keyboard icon.
- Choose The mouse, User clicks on an object from the
pop-up menu.
- In the Mouse click dialog box, enable the Left button
and Single click radio buttons.
- Click OK to accept the type of click.
- Double click the Active object icon. A new condition
will appear in the Event Editor list that states "User clicks with left button on Active object
1".
- Find the empty grid box that corresponds to the new
condition and is under the Counter icon. Click this grid box with the right mouse button.
- Choose Set counter from the pop-up menu.
- Type 0 in the text box.
- Click OK. An action marker will appear in the grid box
to show that the action "Set counter to 0" has been set.
This final event will stop the active object from
following the mouse. Now when you run your application you can double click the active object,
drag it to a new position, and single click the object to drop it into place.
Advanced Dragging and Dropping
This procedure for simulating Dragging and Dropping is
more complicated than the above method. The advanced procedure may be more suited for
drag-and-drop applications that include many draggable objects. This method involves a couple
of the more advanced Click & Create functions.
To demonstrate the advanced dragging and dropping, you
will need to place the following objects on the Frame Editor playfield: a counter object and three
active objects.
In the Frame Editor, group the active objects. By
grouping them, you will require fewer event entries to detect when an object has been clicked.
- In the Frame Editor, click Active object 1 with the right
mouse button.
- Choose Object Preferences from the pop-up menu.
- In the Object handling tab, click the Add button.
- From the collection of objects, click the Number 1
qualifier and click OK.
- Click OK again to return to the Frame Editor.
- Repeat steps 1-5 for each of the active objects. This will
create a group of active objects that will appear in the Event Editor as Group 1.
Now in the Event Editor, set an event to have the mouse
pointer pick up the object.
- In the Event Editor, click the New condition box and
double click the Mouse pointer and keyboard icon.
- Choose The mouse, User clicks on an object from the
pop-up menu.
- In the Mouse click dialog box, enable the Left button
and Double click radio buttons.
- Click OK to accept the type of click.
- Double click the Group 1 icon. A new condition will
appear in the Event Editor list that states "User double-clicks with left button on Group
1".
- Find the empty grid box that corresponds to the new
condition and is under the Counter icon. Click this grid box with the right mouse button.
- Choose Set counter from the pop-up menu.
- Click the Edit box and click Retrieve data from an
object.
- Double click the Group 1 icon and choose Values,
Retrieve fixed value from the pop-up menu.
- Click OK to accept the settings. An action marker will
appear in the grid box to show that the action "Set Counter to Fixed("Group
1")" has been set.
To optimize the process a little, we're going to program
the event to drop the object, even though, we haven't started moving any objects. To set the event
to drop the active object:
- Click the New condition box and double click the
Mouse pointer and keyboard icon.
- Choose The mouse, User clicks on an object from the
pop-up menu.
- In the Mouse click dialog box, enable the Left button
and Single click radio buttons.
- Click OK to accept the type of click.
- Double click the Group 1 icon. A new condition will
appear in the Event Editor list that states "User clicks with left button on Group 1".
- Find the empty grid box that corresponds to the new
condition and is under the Counter icon. Click this grid box with the right mouse button.
- Choose Set counter from the pop-up menu.
- Type 0 in the text box.
- Click OK. An action marker will appear in the grid box
to show that the action "Set counter to 0" has been set.
Finally, you need to create the condition which sets the
objects in motion:
- Click the new condition box and double click the
Counter icon.
- Choose Compare the counter to a value from the pop-up
menu.
- Click the Edit button and click Retrieve data from an
object.
- Double click Active object 1 and choose Values,
Retrieve fixed value from the pop-up menu. Click OK.
- Click OK to return to the Event Editor. A new condition
"Counter 1 = Fixed("Active object 1")" will be displayed in the Event
Editor.
- Duplicate the "Counter 1 = Fixed("Active
object 1")" condition twice and change the Active object in each of the new entries to
Active object 2 and Active object 3 respectively.
- Find the empty grid box that corresponds to the
"Counter 1 = Fixed("Active object 1")" condition and is under the Active
object 1 icon. Click this grid box with the right mouse button.
- Choose Current X position of the mouse from the
pop-up menu.
- Click OK to accept the function. An action marker will
appear in the grid box to show that the action "Set X position to XMouse" has been
set.
- Click the same grid box again with the right mouse
button.
- Choose Position, Set Y coordinate from the pop-up
menu.
- Click the Edit button and click Retrieve data from an
object.
- Double click the Mouse pointer and keyboard icon.
- Choose Current Y position of the mouse from the
pop-up menu.
- Click OK to accept the function. An action marker will
appear in the grid box to show that the action "Set Y position to YMouse" has been
set. position to YMouse" has been set.
- Duplicate the X position and Y position actions for each
of the Active object 2 and 3 conditions. These actions should be in the grid box under the icons
for Active object 2 and 3 respectively.
When you run the application, you will be able to imitate
dragging and dropping with Click & Create.
![[Click here for
previous tip]](/deadend) ![[Click here
for next tip]](/deadend)
|
Click &
Create
|