Question About DC_SetAppFocus

This forum is for eXpress++ general support.
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question About DC_SetAppFocus

#11 Post by rdonnay »

Here is a technique you may want to try. It will override the eXpress++ navigation.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

#xTranslate SetFocus(<cId>)  => PostAppEvent(xbeP_User+1,,,DC_GetObject(GetList,<cId>))

FUNCTION Main()

RETURN NewQuantity()

* ------------


FUNCTION NewQuantity()

local cItem, nOldQty, nNewQty, bSayQty, oFrame, getlist:={}, GetOptions

cItem    := SPACE(20)
nOldQty  := 0
nNewQty  := 0

DCUSEREVENT xbeP_User+1 ACTION {|a,b,o|SetAppFocus(o),DC_ClearEvents()}

@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RAISEDBOX ;
   OBJECT oFrame ;
   SIZE 70,15

   @  2,2 DCSAY "Item" GET cItem   ;              // enter inventory item
      PICTURE "@!"                 ;
      PARENT oFrame                ;
      GETID 'GetItem'              ;
      VALID {|| nOldQty:=GetOldQty(cItem)                         ;
              , DC_GetRefresh(getlist)                            ;
              , SetFocus('GetNewQty') ;
              , .T. }

   bSayQty := {|| "Old Quantity" + STR(nOldQty,5,0) }  // show existing qty

   @ 4,2 DCSAY bSayQty  ;
      PARENT oFrame

   @ 6,2 DCSAY "New Quantity" GET nNewQty  ;          // get new quantity
      PICTURE "99999"                      ;
      PARENT oFrame                        ;
      GETID 'GetNewQty'                    ;
      VALID {|| SetFocus('YesButton') ;
              , .T. }

  @ 9, 2 DCPUSHBUTTON     ;                // write new quantity to file
           CAPTION "Yes"   ;
           PARENT oFrame   ;
           SIZE 13,1.5     ;
           ID 'YesButton'  ;
           ACTION {|| UpdateQty(cItem,nNewQty)  ;
                    , cItem := SPACE(20)        ;
                    , nOldQty := 0              ;
                    , nNewQty := 0              ;
                    , DC_GetRefresh(getlist)    ;
                    , SetFocus('GetItem') }

   @ 9,22 DCPUSHBUTTON  ;                       // no write, clear gets
           CAPTION "No"   ;
           PARENT oFrame  ;
           SIZE 13,1.5    ;
           ACTION {|| cItem := SPACE(20)        ;
                    , nOldQty := 0              ;
                    , nNewQty := 0              ;
                    , DC_GetRefresh(getlist)    ;
                    , SetFocus('GetItem') }

   @ 9,42 DCPUSHBUTTON   ;                     // exit this routine
           CAPTION "Exit" ;
           PARENT oFrame  ;
           SIZE 13,1.5    ;
           ACTION {|| DC_ReadguiEvent(DCGUI_EXIT_OK,Getlist) ;
                    , DC_GetRefresh(getlist) }


DCREAD GUI FIT MODAL

RETURN NIL   //////////////////////////////////////////////////////////////


STATIC FUNCTION GetOldQty(cItem)
// locate item in dbf file and return quantity
RETURN 99

STATIC FUNCTION UpdateQty(cItem,nNewQty)
// update dbf with new quantity
RETURN NIL
The eXpress train is coming - and it has more cars.

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: Question About DC_SetAppFocus

#12 Post by GeneB »

Nice.
This makes it so much easier to build "mouseless" screens primarily for data entry, which is the main complaint raised by touch typists converting from a Clipper program.
And so simple.
Thanks again for your help.
GeneB

User avatar
sdenjupol148
Posts: 151
Joined: Thu Jan 28, 2010 10:27 am
Location: NYC

Re: Question About DC_SetAppFocus

#13 Post by sdenjupol148 »

Hi Gene,

If I understand your question correctly, you want to move to a push button just by hitting <ENTER>.
As you know, you can get to your pushbutton with <TAB> since it is the Default windows behavior.

But to enable navigation through the use of <ENTER>;

Add GetOptions to your LOCAL items as in: local cItem, nOldQty, nNewQty, bSayQty, oFrame, getlist:={}, GetOptions

Then on the line before DCREAD GUI add the line: DCGETOPTIONS ENTERTAB

Lastly add OPTIONS GetOptions to your DCREAD GUI line as in: DCREAD GUI FIT MODAL DCREAD GUI FIT MODAL OPTIONS GetOptions

-or-

If the <ENTER> key navigation over-ride does not work for you, you can setfocus to an object within the VALID clause.
In the case of your code, the 'New Quantity' GET would be written this way:
@ 6,2 DCSAY "New Quantity" GET nNewQty ; // get new quantity
PICTURE "99999" ;
PARENT oFrame ;
GETID 'GetNewQty' ;
VALID {|| {.T., DC_SetAppFocus(DC_GetObject(getlist,'YesButton')) } }

Add whatever code you need executed in the VALID clause but the last item must be an array.
The first item in that array is the TRUE or FLASE value of the VALID and the second item is the OBJECT that needs focus.

Hope this helps you

Bobby

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: Question About DC_SetAppFocus

#14 Post by GeneB »

Thanks, Bobby, I appreciate your help.
GeneB

Post Reply