Page 1 of 2

Question About DC_SetAppFocus

Posted: Sun Jul 31, 2011 5:24 pm
by GeneB
In the following code, DC_SetAppFocus from the 'new quantity' to the 'yes' button doesn't happen. Could someone kindly tell me what I'm missing, doing wrong, or a better way to do it?
Thanks.
GeneB

Code: Select all

FUNCTION NewQuantity()

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

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

@ 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)                            ;
              , DC_SetAppFocus(DC_GetObject(getlist,'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 {|| DC_SetAppFocus(DC_GetObject(getlist,'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)    ;
                    , DC_SetAppFocus(DC_GetObject(getlist,'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)    ;
                    , DC_SetAppFocus(DC_GetObject(getlist,'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

Re: Question About DC_SetAppFocus

Posted: Mon Aug 01, 2011 5:45 pm
by GeneB
Let me rephrase the question.

Is it possible to set the app focus from within a VALID of a DCGET to a DCPUSHBUTTON ?

Re: Question About DC_SetAppFocus

Posted: Tue Aug 02, 2011 6:51 am
by rdonnay
Yes, there is a way, but you must first disable the automatic navigation that is built into the eXpress++ event loop.

The DC_SetAppfocus() calls that you have in your code now are not doing anything. The eXpress++ navigation system automatically moves you to the next object in the GetList.

Let me work with your code and see what I can do.

Re: Question About DC_SetAppFocus

Posted: Tue Aug 02, 2011 11:51 am
by RDalzell
Gene,

I place a function within the VALID, that function performs the getlist refresh and the dc_setappfocus, and returns .t.

Re: Question About DC_SetAppFocus

Posted: Tue Aug 02, 2011 2:47 pm
by GeneB
Thanks, Rick, for your input.
This works for setting the focus to another DCGET, but not to a DCPUSHBUTTON.
Gene

Re: Question About DC_SetAppFocus

Posted: Tue Aug 02, 2011 6:59 pm
by rdonnay
This works for me:

Code: Select all

DCGETOPTIONS ENTERTAB TABSTOP

DCREAD GUI FIT MODAL OPTIONS GetOptions

Re: Question About DC_SetAppFocus

Posted: Wed Aug 03, 2011 7:48 pm
by GeneB
Thanks, Roger, that works perfectly in my test program.
When I added the Get Options to my 'real time' program, one of the other Gets stopped working correctly. I'll post it here when I figure out what conflicts.
Thanks again.
GeneB

Re: Question About DC_SetAppFocus

Posted: Thu Aug 04, 2011 7:40 am
by rdonnay
What you are trying to do is manage your own navigation and this can alway be tricky because it can conflict with the built-in navigation of eXpress++. I think that it's time to add a new way of handling this. I was thinking about this on my walk this morning to Starbucks and I may have an idea that will deal with this issue once and for all. I will give this more thought when I get back home.

Re: Question About DC_SetAppFocus

Posted: Thu Aug 04, 2011 8:53 am
by GeneB
Thanks, Roger. I suspect that my immediate problem is a HIDE on the button I am setting to the focus to, but I haven't had time to verify that.
GeneB

Re: Question About DC_SetAppFocus

Posted: Thu Aug 04, 2011 11:50 am
by GeneB
HIDE seems to be the culprit. Avoiding them in the DCGETS involved ended my problems. It is working fine so far for what I need.
Thank you
GeneB