Assuming VF will declare controls in a fashion similar to LB, it will need to use arrays of many different object types. The following examples concentrate on menus.
First, a simple menu in LB might look like
Code: |
Menu #File, "&File", "&Open...", FileOpen, |, "E&xit", FileExit |
The same code should work exactly the same in VF. However, that syntax is rather hard to read and limits the addition of new features.
Here's basically the same menu declared with some different syntax.
Code: |
begin Menu #File, "&File"
"&open", FileOpen, #Key Ctrl("O") |-- "E&xit", FileExit end Menu |
The Begin keyword introduces an object declaration that takes an array as its last parameter. Each element in the array is written on a single line. The declaration terminates with an End X, where X is the type of object.
The only difference between the first example and the second is that the latter adds "Ctrl+O" to the first menu item. The third parameter is optional and is being passed the result of the Ctrl() method that #Key implements.
The vertical bar ("|") in VF is a synonym for #Null, the value of an uninitialized object handle. The symbol can be written with any number of trailing hyphens. Its meaning depends on the object it's passed to. For a menu, it follows LB's convention of creating a separator.
The final example creates a "zoom" menu that might be used in a document viewing/editing application to control the size of the text and/or graphics on the screen.
Code: |
begin Menu #Zoom, "&Zoom"
"Zoom &in", ZoomIn, #Key Ctrl("+") "Zoom &out", ZoomOut, #Key Ctrl("-") begin RadioGroup(Number), ZoomBy, 100 "&50%", 50 "&75%", 75 "1&00%", 100 ' the default as specified above "&150%", 150 "&200%", 200 "&400%", 400 end RadioGroup end Menu |
Here RadioGroup inherits from the same base class as MenuItem which allows it to be used in its place. Additionally, RadioGroup is a parameterized type which is passed the type of the key associated with each item. Its two "normal" parameters are (1) a shared event handler that will be passed the clicked item's key, and (2) the key of the default item.