DEFINE BUTTON statement
The DEFINE BUTTON statement defines a push button that is created at compile time for use within the current procedure or class.
Note: Does not apply to SpeedScript programming.Syntax
[ PRIVATE ] BUTTONbutton
Defines and identifies a button widget as a class-scoped object. A class-scoped handle-based object is not a member of a class, but provides a resource that is privately available to the class definition similar to a non-shared data element in a procedure definition. The option to specify the PRIVATE access mode is provided for readability. You cannot specify PRIVATE when defining a button widget as a data element in a method or procedure.Note: This option is applicable only when defining a class-scoped button widget in a class definition (.cls
) file.BUTTONbutton
AUTO-END-KEYAUTO-GODEFAULT
Specify DEFAULT to indicate that the button is a default button. A default button is one that handles all RETURN events when no other RETURN-enabling widget in the frame or dialog box has focus. RETURN-enabling widgets include any field-level widget for which a RETURN trigger is defined, or any button, whether or not it has a trigger defined. Thus, if a button has focus, that button handles the next RETURN event. If any other field-level widget without a RETURN trigger has focus, the default button handles the next RETURN event.To make the button the default button for the frame in which it resides, you must also set the frame’s DEFAULT-BUTTON option.BGCOLORexpression
CONTEXT-HELP-IDexpression
DCOLORexpression
FGCOLORexpression
FONTnumber
{IMAGE | IMAGE-UP }image-phrase
An image that you want to appear within the button when the button is in its up state. If the image does not have a down state, for code readability you might want to use the IMAGE option instead of the IMAGE-UP option.The IMAGE | IMAGE-UPimage-phrase
option is ignored in character interfaces.The syntax ofimage-phrase
is as follows:
For more information on this syntax, see the Image phrase reference entry.IMAGE-DOWNimage-phrase
An image that you want to appear within the button when the button is in its down state. The IMAGE-DOWN option is ignored in character interfaces.For more information, see the Image phrase reference entry.Note: The AVM draws the 3D effect only if a button has an up image, but no down image.IMAGE-INSENSITIVEimage-phrase
An image you want to appear within the button when the button is in its insensitive (disabled) state. This option is ignored in character interfaces.For more information, see the Image phrase reference entry.MOUSE-POINTERname
LABELlabel
The label displayed on the button. The name should describe the action invoked when the button is chosen. The value oflabel
must be a string enclosed in quotes. The default label is the button name. If you use the LIKEbutton
option and you do not use the LABEL option, the button inherits the label of the button you name.You can indicate a character within the label to be used as a navigation mnemonic in Windows. Indicate the character by preceding it with an ampersand (&). When the button is displayed, the mnemonic is underlined. The user can choose the button by pressing ALT and the underlined letter. If you specify more than one button with the same mnemonic, the AVM transfers focus to each of these in tab order when you make a selection.To include a literal ampersand within a label, specify a double ampersand (&&).LIKEbutton
Indicates the name of a defined button whose characteristics you want to use for a new button. If you name a button with this option, you must have defined that button earlier in the procedure. You can override the label, image, and on phrase by using the LABEL, IMAGE, andon-phrase
options. If you do not use these options, the button takes on the characteristics of the button you name.PFCOLORexpression
size-phrase
Specifies the outside dimensions of the button widget. Following is the syntax for size-phrase:
If you specify SIZE or SIZE-CHARS, the units are characters; if you specify SIZE-PIXELS, the units are pixels. For character units, the valueswidth
andheight
must be decimal constants; for pixel units, they must be integer constants. For more information, see the SIZE phrase reference entry.If no size is specified, the AVM calculates a default size for the button. This calculation adds the button’s border thickness (that is, the combination of 3D shadows and highlights, and the focus rectangle) to the up image size defined by the IMAGE | IMAGE-UPimage-phrase
option. However, the thickness of the border depends on whether the button has dual images (up and down images) and whether it is a FLAT-BUTTON or NO-FOCUS button.Table 27 explains how many pixels the image size expands based on the button size.
NO-FOCUS [ FLAT-BUTTON ]
Specifies that the button should not accept focus. A button for which the NO-FOCUS attribute is defined will not take focus when the mouse is clicked on it, and it will not accept keyboard input. Also, the AVM will not generate ENTRY or LEAVE events for the button. NO-FOCUS buttons behave similarly to standard Windows toolbar buttons. The NO-FOCUS option is supported in Windows only.A button with the NO-FOCUS attribute is not added to its parent frame’s tab order. However, if the NO-FOCUS attribute is switched from TRUE to FALSE before the button is realized, the button is added to the end of its parent frame’s tab order. Switching the NO-FOCUS attribute from FALSE to TRUE before realization removes the button from its parent frame’s tab order.Note: If a frame that contains a NO-FOCUS button does not itself have focus, the frame does not receive focus when the button is pushed. In this situation, frame entry or leave events are not generated. Focus stays on the current widget when a NO-FOCUS button is pushed, even across multiple frames in a window.FLAT-BUTTONNO-CONVERT-3D-COLORS
Specifies that the colors of the button’s images (that is, up, down, and insensitive) are not converted to the system 3D colors. By default, the AVM converts shades of gray in an image to the corresponding system 3D color. Using the NO-CONVERT-3D-COLORS option overrides this default behavior. The NO-CONVERT-3D-COLORS option is supported in Windows only.Table 28 describes the conversion process.
During a session, if Windows notifies the AVM that the system colors have changed, the button’s images are re-loaded and converted to the new system colors, unless the NO-CONVERT-3D-COLORS option is specified.TOOLTIPtooltip
Allows you to define a help text message for a button. The AVM automatically displays this text when the user pauses the mouse pointer over the button.You can add or change the TOOLTIP option at any time. If TOOLTIP is set to "" or the Unknown value (?
), then the ToolTip is removed from the button. No ToolTip is the default. ToolTips are supported in Windows only.DROP-TARGETtrigger-phrase
Specifies application triggers for the button.For more information, see the Trigger phrase reference entry.ExampleThis procedure defines two buttons, positions the buttons within a form, assigns triggers to the buttons with ON statements, and enables the buttons by referencing them in an ENABLE statement:
When the procedure is run, the first Customer’s number and name are initially displayed. The user can choose either the MORE button to see the entire Customer record or the NEXT button to see the next Customer’s number and name.
The following example sets up a browse that allows you to drop a file on the browse:
Notes
- When a frame receives a default RETURN event, it actually sends a CHOOSE event to the default button.
- To create the compile-time defined button you are defining, you must define a compile-time defined frame that contains the button. Each frame you define that contains the same button creates an additional instance of that button. The handle for a compile-time defined button is not available until the button is created.
- You must enable a button to make it available to the user. You can enable a button by setting its SENSITIVE attribute or by referencing it in an ENABLE or UPDATE statement.
- On a character-based terminal, a button appears as the label enclosed in angle brackets (< >). The user can move the mouse pointer to the button by pressing TAB or arrow keys. The user can then choose the button by pressing SPACEBAR or RETURN.
- You can specify an application-defined widget ID for a compile-time defined button widget using the
form-item
phrase in either the FORM statement or the DEFINE FRAME statement. See the FORM statement and DEFINE FRAME statement reference entries for more information.- To make an application portable between graphical and character environments, you can specify an image and a label for a button. In graphical environments, the image is used and the label is ignored; in character environments, the label is used and the image is ignored.
- If you specify a size for a button, the button is not affected by changes to the size of any contained image. If you do not specify a size for the button, the button changes size to fit the image.
- In Windows, ABL supplies the following prepackaged images for the up, down, left, and right arrows:
btn-up-arrow
,btn-down-arrow
,btn-left-arrow
, andbtn-right-arrow
. Specify one of these items in place of a filename.Use these values for the IMAGE-UP option. Doing so makes the prepackaged image available to ABL in its up, down, and insensitive state, without specifying the IMAGE-DOWN and the IMAGE-INSENSITIVE options. You will also get appropriately sized arrows based on your screen resolution.- You can apply entry to a NO-FOCUS button programmatically. The AVM does not report an error. However, the button will not respond to keyboard activity.
- The AVM draws the 3D effect only if a button has an up image, but no down image. If the button has both an up image and a down image, the AVM does not draw the 3D effect; the images, themselves, should be drawn with a 3D effect.
- The AVM only performs the color conversion process on bitmaps (
.bmp
files) that contain 256 or fewer colors. However, you might consider using 16-color bitmaps because only the first sixteen entries in the bitmap’s color table will be converted.- Icon colors (
.ico
files) are not converted, even if CONVERT-3D-COLORS is TRUE. To ensure that an icon will be displayed properly on a button, draw icons with a transparent background.See alsoClass-based data member access, FORM statement, Image phrase
OpenEdge Release 10.2B
|