Toolbar Component
Fnd_Tlbr_Button_Add
Fnd_Tlbr_Button_Add (name; button text; icon name; method{; keystroke})
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | Text | Unique name for the button object |
| button text | Text | Button label |
| icon name | Text | Picture Library name for the icon |
| method | Text | The method to call when the button is clicked |
| keystroke | Text | Command/Ctrl keyboard equivalent (optional) |
Description
Fnd_Tlbr_Button_Add adds a new button to the toolbar. The button is always appended to the right of any existing toolbar buttons or dividers. The button name is used to identify the button when calling other Toolbar component methods. It should be a unique string of up to 31 characters. The second parameter is the text label to be displayed with the button. This label can later be changed on- the-fly by calling the Fnd_Tlbr_Button_Label function. This label is limited to 80 characters. The third parameter is the name of an icon for the new button. Any of the icons built into the Foundation Buttons component can be used. Your own custom icons can also be used. See the Buttons Component (Fnd_Bttn) chapter for the complete list of built-in icons and instructions for using custom icons. The fourth parameter is the name of a method or any string that will work properly with 4D’s EXECUTE command. This string will be executed if the button is clicked. For example, this code will add a button to the toolbar with a label of “Delete” and the Red X icon from the Buttons component. It will call the DeleteRecords method when clicked:
Fnd_Tlbr_Button_Add ("Button1";"Delete";"Fnd_Bttn_RedX";"DeleteRecords")
This line will have the same appearance, but will call 4D’s DELETE RECORDS command directly:
Fnd_Tlbr_Button_Add ("DelBttn";"Delete";"Fnd_Bttn_RedX";"DELETE RECORDS([Invoices])")
Note that although the example above may work, it is best to use 4D’s Command name function to get the localized command name, and to get the table name dynamically, rather than hard-coding it:
$execute_t:=Command name(58)+"("+Table name(->[Invoices])+"])"
Fnd_Tlbr_Button_Add ("DelBttn";"Delete";"Fnd_Bttn_RedX";$execute_t)
You can optionally assign a key equivalent to the button. The user can then use this keyboard equivalent rather than use the mouse to click the button. On Macintosh, the user will hold down the Command key and press the specified key. On Windows, the Control key is used. This key can be any letter A-Z, any number 0-9, or one of these special values: Backspace Delete Period UpArrow DownArrow RightArrow LeftArrow For example, this line lets the user run the DuplicateRecord method by typing Command-D on Macintosh or Control-D on Windows:
Fnd_Tlbr_Button_Add ("DupBttn";"Dupe Rec";"Fnd_Bttn_Duplicate";"DuplicateRecord";"D")
This line lets the user delete records by typing Command-Backspace on Macintosh or Control-Backspace on Windows:
Fnd_Tlbr_Button_Add ("DelBttn";"Delete";"Fnd_Bttn_RedX";"DeleteRecords";"Backspace")
After calling this command, the Fnd_Tlbr_Redraw command should be called to update the toolbar.
Extracted source text
Fnd_Tlbr_Button_Add (name; button text; icon name; method{; keystroke})
Parameter Type Description
name Text Unique name for the button object
button text Text Button label
icon name Text Picture Library name for the icon
method Text The method to call when the button is clicked
keystroke Text Command/Ctrl keyboard equivalent (optional)
Fnd_Tlbr_Button_Add adds a new button to the toolbar. The button is always appended to the right of
any existing toolbar buttons or dividers.
The button name is used to identify the button when calling other Toolbar component methods. It
should be a unique string of up to 31 characters.
The second parameter is the text label to be displayed with the button. This label can later be changed on-
the-fly by calling the Fnd_Tlbr_Button_Label function. This label is limited to 80 characters.
The third parameter is the name of an icon for the new button. Any of the icons built into the Foundation
Buttons component can be used. Your own custom icons can also be used. See the Buttons Component
(Fnd_Bttn) chapter for the complete list of built-in icons and instructions for using custom icons.
The fourth parameter is the name of a method or any string that will work properly with 4D’s EXECUTE
command. This string will be executed if the button is clicked.
For example, this code will add a button to the toolbar with a label of “Delete” and the Red X icon from
the Buttons component. It will call the DeleteRecords method when clicked:
Fnd_Tlbr_Button_Add ("Button1";"Delete";"Fnd_Bttn_RedX";"DeleteRecords")
This line will have the same appearance, but will call 4D’s DELETE RECORDS command directly:
Fnd_Tlbr_Button_Add ("DelBttn";"Delete";"Fnd_Bttn_RedX";"DELETE RECORDS([Invoices])")
Note that although the example above may work, it is best to use 4D’s Command name function to get
the localized command name, and to get the table name dynamically, rather than hard-coding it:
$execute_t:=Command name(58)+"("+Table name(->[Invoices])+"])"
Fnd_Tlbr_Button_Add ("DelBttn";"Delete";"Fnd_Bttn_RedX";$execute_t)
You can optionally assign a key equivalent to the button. The user can then use this keyboard equivalent
rather than use the mouse to click the button. On Macintosh, the user will hold down the Command key
and press the specified key. On Windows, the Control key is used. This key can be any letter A-Z, any
number 0-9, or one of these special values:
Backspace
Delete
Period
UpArrow
DownArrow
RightArrow
LeftArrow
For example, this line lets the user run the DuplicateRecord method by typing Command-D on
Macintosh or Control-D on Windows:
Fnd_Tlbr_Button_Add ("DupBttn";"Dupe Rec";"Fnd_Bttn_Duplicate";"DuplicateRecord";"D")
This line lets the user delete records by typing Command-Backspace on Macintosh or Control-Backspace
on Windows:
Fnd_Tlbr_Button_Add ("DelBttn";"Delete";"Fnd_Bttn_RedX";"DeleteRecords";"Backspace")
After calling this command, the Fnd_Tlbr_Redraw command should be called to update the toolbar.