xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

@...GET PUSHBUTTON

Creates a Get object as push button and displays it to the screen.

Syntax

 @ <nRow>, <nCol> ;
       GET <lLogicVar> ;
PUSHBUTTON ;
  [CAPTION <cCaption>] ;
  [MESSAGE <cMessage>] ;
     [WHEN <lWhen>] ;
    [VALID <lValid>] ;
    [COLOR <cColor>] ;
    [FOCUS <bFocus>] ;
    [STATE <bState>] ;
    [STYLE <cStyle>] ;
     [SEND <msg>] ;
  [GUISEND <guimsg>]

Arguments

@ <nRow>, <nCol>
The parameters are numeric values specifying the row and column coordinates for the screen output. The range for rows on the screen is 0 to MaxRow(), and for columns it is 0 to MaxCol(). The coordinate 0,0 is the upper left corner of the screen.
GET <lLogicVar> PUSHBUTTON
This is a memory or field variable holding a logical value. It is required as a place holder for the Get, and is set to .F. (false) when the READ command is terminated.
CAPTION <cCaption>
This is a character string displayed as caption of the push button. The caption string may include an ampersand character (&) which marks the next character as accelerator key. Pressing the Alt key together with the accelerator key allows the user to jump directly to the push button.
MESSAGE <cMessage>
This is an optional character string displayed in the message row when the push button has input focus. The message row is defined with the MSG AT option of the READ command.
WHEN <lWhen>
This is a logical expression or a code block returning a logical value. If specified, <lWhen> must result in .T. (true) to allow editing. If the expression yields .F. (false), the push button cannot receive input focus.
VALID <lValid>
This is a logical expression or a code block returning a logical value. If specified, <lValid> must result in .T. (true) to end editing. When the result is .F. (false), the push button retains input focus and READ cannot be ended unless editing is cancelled.
COLOR <cColor>
The parameter <cColor> is an optional character string defining the colors for the display of the push button. It defaults to the current SetColor() setting. <cColor> must have four color values (see ColorSelect()). They are used as follows:

Color values for push buttons
Color valueDescription
1Color when the push button does not have input focus
2Color when the push button has input focus
3Color for the push button is pressed
4Color for the push button's accelerator key

FOCUS <bFocus>
This is an optional code block which is evaluated when the push button receives input focus. The code block is evaluated without parameters.
STATE <bState>
This is an optional code block which is evaluated when the push button's state is changed by the user. The code block is evaluated without parameters.
STYLE <cStyle>
An optional character string of zero, two or eight characters defines the display style. It defaults to "<>" which are the left and right delimiting characters of the push button. When a null string is used for <cStyle>, no delimiting characters are used.

A character string of eight characters defines the border drawn around the pushbutton. They are used in the same way as with the DispBox() function. The #define constants available in Box.ch can be used:

Constants for borders
ConstantDescription
B_SINGLESingle-line border
B_DOUBLEDouble-line border
B_SINGLE_DOUBLESingle-line top, double-line sides
B_DOUBLE_SINGLEDouble-line top, single-line sides

If <cStyle> has eight characters, the push button has a height of three screen rows, otherwise it is displayed in one screen row.

SEND <msg>
This is an optional message to be sent to the Get object before it is displayed. Refer to the Get class for possible messages that can be sent to the Get object.
GUISEND <guimsg>
This is an optional message to be sent to the HbPushButton() object associated with the Get() object before both are displayed. Refer to the HbPushButton class for possible messages that can be sent to the push button object.

Description

The @...GET PUSHBUTTON command creates a Get() object and assigns a HbPushButton() object to the oGet:control instance variable. The HbPushButton() object displays a push button in text mode and allows a user to press it while the READ command is active. The variable <lLogicVar> contains always .F. (false) when READ is terminated.

The Get object created with @...GET PUSHBUTTON is stored in the current Getlist array. The Get object communicates with the associated HbPushButton object while the READ command is active. This communication ensures that focus and state changes are properly displayed on the screen.

Info

See also:@...GET, Get(), HbPushButton()
Category: Get system , Input commands
Source:rtl\pushbtn.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates how push buttons can be integrated
// in the Get list and are activated during READ

   PROCEDURE Main
      LOCAL cLName, cFName
      LOCAL lBtn1   := .F.
      LOCAL lBtn2   := .F.
      LOCAL lBtn3   := .F.
      LOCAL nBtn    := 0
      LOCAL cGetClr := "W+/B,W+/R,N/BG,GR+/BG"
      LOCAL cBtnClr := "N/G,W+/G,GR+/N,GR+/G"

      SET EVENTMASK TO INKEY_ALL
      SET COLOR TO N/BG
      CLS

      USE Customer ALIAS Cust
      cFName := Cust->FirstName
      cLName := Cust->LastName

      @  8, 20 GET cFName ;
           CAPTION "&First name:" ;
             COLOR cGetClr

      @ 10, 20 GET cLName ;
           CAPTION " &Last name:" ;
             COLOR cGetClr

      @ 12, 20 GET lBtn1 PUSHBUTTON ;
           CAPTION " &Save " ;
             COLOR cBtnClr ;
             STATE {|| nBtn := IsPressed( 1 ) }

      @ 12, 30 GET lBtn2 PUSHBUTTON ;
           CAPTION " &Undo " ;
             COLOR cBtnClr ;
             STATE {|| nBtn := IsPressed( 2 ) }

      @ 12, 40 GET lBtn3 PUSHBUTTON ;
           CAPTION " E&xit " ;
             COLOR cBtnClr ;
             STATE {|| nBtn := IsPressed( 3 ) }

      DO WHILE .T.
         READ SAVE

         DO CASE
         CASE nBtn == 1
            IF RLock()
               REPLACE Cust->FirstName WITH cFName
               REPLACE Cust->LastName  WITH cLName
               DbUnlock()
               EXIT
            ELSE
               Alert( "Unable to save;Retry again later" )
            ENDIF

         CASE nBtn == 2
            cFName := Cust->FirstName
            cLName := Cust->LastName
            nBtn   := 0
            AEval( GetList, {|oGet| oGet:display() } )

         CASE nBtn == 3
            EXIT

         ENDCASE
      ENDDO

      ASize( GetList, 0 )
      CLOSE ALL
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe