Question About DC_SetAppFocus

This forum is for eXpress++ general support.
Message
Author
User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Question About DC_SetAppFocus

#1 Post 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

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

Re: Question About DC_SetAppFocus

#2 Post 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 ?

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question About DC_SetAppFocus

#3 Post 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.
The eXpress train is coming - and it has more cars.

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Question About DC_SetAppFocus

#4 Post by RDalzell »

Gene,

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

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

Re: Question About DC_SetAppFocus

#5 Post by GeneB »

Thanks, Rick, for your input.
This works for setting the focus to another DCGET, but not to a DCPUSHBUTTON.
Gene

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question About DC_SetAppFocus

#6 Post by rdonnay »

This works for me:

Code: Select all

DCGETOPTIONS ENTERTAB TABSTOP

DCREAD GUI FIT MODAL OPTIONS GetOptions
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

#7 Post 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

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question About DC_SetAppFocus

#8 Post 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.
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

#9 Post 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

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

Re: Question About DC_SetAppFocus

#10 Post 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

Post Reply