|
Adding User-Defined Context Menu to Shape
Control handles are defined in the Controls section of the table. Control handles can be used to create shapes with intelligent behavior. They can be associated with a parameter or a group of parameters of a shape, allowing you to easily modify the shape by repositioning its control handle. Many library shapes have control handles.
The Controls section is used to create control handles. To add this section to the table, select Insert Section from the Edit menu. In the Insert Section dialog enable the Control Handles option and click OK. This inserts the Controls section in the table. The section already contains one row.
Example:
In this example, a control handle is added to a group of two rectangles so that the second rectangle move when the control handle is moved.
Create a new document by selecting New Document from the File menu, or pressing the button on the main toolbar. Then choose the Rectangle tool - either from the Drawing Tools toolbar ( ), from the Insert menu, or from the keyboard: Ctrl + 7

Draw two rectangles.
Select them and group using the Group command from the Shape menu.
Now lets display the Parameter Table for the entire group. Press F3 or select Show Table from the Shape menu.
We need to create two sections in the table: the Controls section, describing the control handle, and Variables section, which will be used to pass the coordinates of the control handle from the parent shape to the child shape. Choose Insert Section from the Edit menu and in the dialog enable the Control Handles and Variables options.
Click OK. Two sections - Controls and Variables will be inserted in the table.
Now you need to edit the Variables section so that it contains the coordinates of the control handle.

In the Variables.X1 cell, enter "Controls.X1". In the Variables.Y1 enter "Controls.Y1". Now these values are to be passed to the child shape.
Then, lets protect the control handle from repositioning vertically. To do this, enter 1 in the Controls.YBehavior1 cell.
Select the upper rectangle in the group. Press F3 to call its parameter table. We'll need the Transform section.

In the GPinX cell enter Parent.Width*0.500000+Parent.Variables.X1-Width/2.
This means that when you move the control handle with the mouse horizontally, the upper rectangle will move together with the control handle. You can program much more complex behavior by using the formulas. The libraries contain a lot of shapes with such behavior.
|