Random Options Inlinks Browse Raw Live Wayback Source Home Archives: pcmedia27
http://www.corel.com/clickandcreate/tips/tip5.htm (PC Media Número 27, 1997-02-17)

[Navigation Bar]

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.

  1. Click the New condition box and double click the Mouse pointer and keyboard icon.
  2. Choose The mouse, User clicks on an object from the pop-up menu.
  3. In the Mouse click dialog box, enable the Left button and Double click radio buttons.
  4. Click OK to accept the type of click.
  5. 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".
  6. 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.
  7. Choose Set counter from the pop-up menu.
  8. Type 1 in the Enter expression box.
  9. 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:

  1. Click the New condition box and double click the Counter icon.
  2. Choose Compare the counter to a value from the pop-up menu.
  3. Enable the Equal radio button and type 1 in the Choose expression to compare with box.
  4. Click OK. A new condition will appear in the Event Editor list that states "Counter =1".
  5. 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.
  6. Choose Position, Set X coordinate from the pop-up menu.
  7. Click the Edit button and click Retrieve data from an object.
  8. Choose Current X position of the mouse from the pop-up menu.
  9. Click the same grid box again with the right mouse button.
  10. Choose Position, Set Y coordinate from the pop-up menu.
  11. Click the Edit button and click Retrieve data from an object.
  12. Double click the Mouse pointer and keyboard icon.
  13. Choose Current Y position of the mouse from the pop-up menu.
  14. 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:

  1. Click the New condition box and double click the Mouse pointer and keyboard icon.
  2. Choose The mouse, User clicks on an object from the pop-up menu.
  3. In the Mouse click dialog box, enable the Left button and Single click radio buttons.
  4. Click OK to accept the type of click.
  5. 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".
  6. 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.
  7. Choose Set counter from the pop-up menu.
  8. Type 0 in the text box.
  9. 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.

  1. In the Frame Editor, click Active object 1 with the right mouse button.
  2. Choose Object Preferences from the pop-up menu.
  3. In the Object handling tab, click the Add button.
  4. From the collection of objects, click the Number 1 qualifier and click OK.
  5. Click OK again to return to the Frame Editor.
  6. 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.

  1. In the Event Editor, click the New condition box and double click the Mouse pointer and keyboard icon.
  2. Choose The mouse, User clicks on an object from the pop-up menu.
  3. In the Mouse click dialog box, enable the Left button and Double click radio buttons.
  4. Click OK to accept the type of click.
  5. 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".
  6. 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.
  7. Choose Set counter from the pop-up menu.
  8. Click the Edit box and click Retrieve data from an object.
  9. Double click the Group 1 icon and choose Values, Retrieve fixed value from the pop-up menu.
  10. 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:

  1. Click the New condition box and double click the Mouse pointer and keyboard icon.
  2. Choose The mouse, User clicks on an object from the pop-up menu.
  3. In the Mouse click dialog box, enable the Left button and Single click radio buttons.
  4. Click OK to accept the type of click.
  5. 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".
  6. 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.
  7. Choose Set counter from the pop-up menu.
  8. Type 0 in the text box.
  9. 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:

  1. Click the new condition box and double click the Counter icon.
  2. Choose Compare the counter to a value from the pop-up menu.
  3. Click the Edit button and click Retrieve data from an object.
  4. Double click Active object 1 and choose Values, Retrieve fixed value from the pop-up menu. Click OK.
  5. Click OK to return to the Event Editor. A new condition "Counter 1 = Fixed("Active object 1")" will be displayed in the Event Editor.
  6. 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.
  7. 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.
  8. Choose Current X position of the mouse from the pop-up menu.
  9. 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.
  10. Click the same grid box again with the right mouse button.
  11. Choose Position, Set Y coordinate from the pop-up menu.
  12. Click the Edit button and click Retrieve data from an object.
  13. Double click the Mouse pointer and keyboard icon.
  14. Choose Current Y position of the mouse from the pop-up menu.
  15. 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.
  16. 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][Click here
for next tip]

SEARCH

Click & Create

 


created with Corel WEB.DESIGNEROther useful links:
|
Copyright Information |