Form_Button - DfBaseForm

Allows you to define and place a button within your form

Type: Property

Access: Read/Write

Data Type: Integer

Parameters: Integer iItem

ParameterDescription
iItem (Optional)The item number (0 if omitted).


Syntax
 Property Integer Form_Button

Read Access: Get Form_Button [iItem] to IntegerVariable
Write Access: Set Form_Button [iItem] to IntegerVariable/Value


Description

This is a low level interface. If you need a prompt button or a spin button, sub-classes have been provided to support this at a higher level (SpinForm, dbSpinForm, dbForm). You should use Prompt_Button_Mode for this in most cases.

Valid values:

ConstantMeaning
Form_Button_None no button
Form_Button_Prompt prompt button
Form_Button_Spin spin button that does not wrap
Form_Button_Spin_Wrap spin button that wraps


Form_Button allows you to define and place a button within your form. The button will be right justified. This is used in subclasses to create prompt buttons and spin buttons.

Form_Button_Prompt creates a button whose contents will defined by Form_Button_Value. Form_Button_Spin creates a spin button and Form_Button_Spin_Wrap create a spin button that will wrap when button value exceeds its maximum or minimum value.

Form Buttons in Grid

Form_Button can also be used to determine what kind of button will appear in a grid column when a cell in that column takes the focus. Normally, you will set this property when you add an item to a grid. Because Grids are lower level classes, you are allowed to set buttons in grids on a column-by-column basis.

Prompts
A prompt button is defined by setting a column's Form_Button to Form_Button_Prompt. If defined, pressing the prompt button will send the message Prompt which, by default, does nothing. It is up to you to decide what to do with this. When Prompt is called, the grid always has the focus and the cell with the prompt is the current_item. Typically, you will use the properties.

// if a column's Form_Button is set to Form_Button_Prompt, 
// pressing the button will call this method
Procedure Prompt
   Integer iCell iColumn

   Get Current_Item to iCell
   Get Current_Col to iColumn
   Send Info_Box ("Prompt for item" + string(iCell) + " in column " + string(iColumn)) "Prompt"
End_Procedure


Spinners
A spin button is defined by setting a column's Form_Button to Form_Button_Spin or Form_Button_Spin_Wrap. If set to Form_Button_Spin, the spinner will stop when it reaches the maximum or minimum value. When set to Form_Button_Spin_Wrap, the spinner will wrap when it reaches an upper or lower limit.

When the spinner is pressed, the message OnInitSpin is called. It is up to you to set the properties minimum_position and maximum_position (which will properly initialize the spinner). Again, you can use current_item and current_col to figure out what you called.

The message DoScrollDown and DoScrollUp can be used to assign keys for the spinners (single item spin forms use the same messages and assign ctrl-up and ctrl-down to them). These are not assigned default keys in grids or dbGrids (because they ctrl-up/down keys are already assigned).

Here is how a sample grid might look:

Object oGrid1 is a Grid
    Set Size to 70 271
    Set Location to 15 15
 
    Set Line_Width to 2 0
 
    Set Form_Width   0 to 168
    Set Header_Label 0 to "Name"
   
    Set Form_Width   1 to 34
    Set Header_Label 1 to "Number"
 
    Procedure FillList
        integer i iCell

        // add 10 rows of data
        For i From 0 to 9
            Get Item_Count to iCell
 
             Send Add_Item 0 ("Name"+string(i))
             
             Send Add_Item 0 i
        Loop
    End_Procedure

    // set first column to use a prompt button
    Set Form_Button 0 to FORM_BUTTON_PROMPT
    Set Form_Button_Value 0 to "..."

    // set second column to use a spin form
    Set Form_Button 1 to FORM_BUTTON_SPIN_WRAP
 
    // this gets called from the first column. 
    Procedure Prompt
        Send Info_Box ("prompt called for " + string(self))
    End_Procedure
 
    // You must set these values each time a spinner is called.
    // In this example the spinner is only in one column and its 
    // value is the same for each cell 
    Procedure onInitSpin
        Set Minimum_Position to 0
        Set Maximum_Position to 10
    End_Procedure
 
    // assign keys to manually spin value
    On_Key Key_Ctrl+Key_U  Send DoScrollUp
    On_Key Key_Ctrl+Key_D  Send DoScrollDown
    // fill the list 
    Send FillList
 
End_Object    // oGrid1


Default is Form_Button_None.

See Also

Info_Box