| Search Locate Previous | Contents |
When you need to maintain a design-time property which is not one of the standard types (txt, num etc.) you should provide a function in the class namespace with the following syntax conventions:
resold MyFn options;new
The Designer will call this with the current value of the property on the left and the function argument on the right (will be passed as '' if none is given). The function should prompt the user for a new value and return it as the second element of the result. If the first element is <1> the Designer will then store this against the property in the dialogue-definition, unless it matches the default value. If the first element is <0> the developer hit <Cancel> and the old value will be left in place. A typical entry in the specification would be:
Limits=3 4 : Constrain 10 200 © Limits on position
Here is a very old-fashioned approach to writing such a function:
resold Constrain list;new © Modify (r,c) pair (always accepts change) 'The old value is ',old 'Please enter a new value in the range ',list new2 'The new value will be ',new res1 new
The Designer will simply show a button labelled with the property name (or the current value if set). When pressed, this will run your function:
The old value is 2 3
Please enter a new value in the range 10 200
:
3 4
The new value will be 3 4
... and the property will be modified. Of course you can use #.CPro.Call here with a standard Causeway form to maintain a more complex property use the return value from the call to set the first element of the result of the property-maintenance function.
Replacing the standard mouse handlers
Custom classes can set up their own mouse handlers to replace the standard menu offered by the Designer or the standard locator behaviour. A typical use would be in a class such as a grid or chart, where you wanted to modify selected details (like the gridlines, or the font of the chart heading) directly from the object in design mode. To replace the standard right-mouse menu with your own behaviour, you must first add an entry into the [Design] block of the specification to name your handler function:
[Design] RightMouseHandler=SetProps © My menu call
This should be Dyadic, result-returning and conform to:
Left Argument
Right Argument
Result
This allows you to check whether the mouse was over some interesting detail, and use your menu if so. Otherwise just return 0 and the Designer will go ahead with its normal menu. If you want to update some values in a hidden property, you will need the id to pass as argument to the SetPropVal call in the Designer.
See the UserTemplate.Template class for an example function MyPopup. A possible use for this would be a chart object where you wanted your own menus on hot areas like headings, but the designer gets to put up the normal menu when you hit the chart background.
The function MyMove shows how you can modify the normal locator behaviour.