Page 1 of 2

gotfocus for dc_tabpage

Posted: Wed Jan 08, 2014 3:10 am
by c-tec
Hello Roger,
it seems that the gotfocus codeblock is called twice every time, what can I do to prevent this ?
regards
Rudolf

Code: Select all

 bGotFocus := {||Build_t2(2,GetList,oBrowse),dc_getrefresh(aoTabMsg[2])}
@  0,0 DCTABPAGE aoTabPage[2] CAPTION '&Transaktionen' RELATIVE aoTabPage[1] STATICAREA aoTabStatic[2];
               GOTFOCUS bGotFocus PARENT oMainStatic ACCELKEY xbeK_ALT_T


...

function build_t2(nTab,aGetlist,oBrowse) 
******************************************************************
local getlist := {}
local getoptions := {}
local nLeft := SIZE_X-20
local nLine := 1
local bColor,oDialog
if !aTabs[nTab]

     @ .5,.5 DCSAY {||DP_KUNNAME} SAYHVCENTER FONT '12.Arial Bold' SAYSIZE SIZE_X - 22,1.4 PARENT aoTabStatic[nTab] COLOR GRA_CLR_YELLOW,GRA_CLR_DARKBLUE OBJECT aoTabMsg[nTab]

     @ 2.1,.5 DCBROWSE oBrowse9 PARENT aoTabStatic[nTab] ALIAS "DOKU" SIZE  SIZE_X-22,SIZE_Y-6   FREEZELEFT { 1 } PRESENTATION cstat("BROWSEPRES") ID 'BROWSE4' SCOPE;
          COLOR {||{GRA_CLR_BLACK,GraMakeRGBColor(cstat("SYS_BROWSECOLOR"))}}  DATALINK {||doku->(edit_doku(0,getlist,"KUN"))} CURSORMODE XBPBRW_CURSOR_ROW ZEBRA {|lEven|zebra(lEven)}

     DCBROWSECOL FIELD doku->nummer     WIDTH 3  HEADER "Nummer"     PARENT oBrowse9  ID 'BROWSE9_1'
     DCBROWSECOL FIELD doku->art        WIDTH 5  HEADER "Art"        PARENT oBrowse9  ID 'BROWSE9_2'
     DCBROWSECOL FIELD doku->TEXT       WIDTH 20 HEADER "Text"       PARENT oBrowse9  ID 'BROWSE9_5'
     DCBROWSECOL FIELD doku->dokument   WIDTH 50 HEADER "Dokument"   PARENT oBrowse9  ID 'BROWSE9_6'
     DCBROWSECOL FIELD doku->user       WIDTH 5  HEADER "User"       PARENT oBrowse9  ID 'BROWSE9_7'
     DCBROWSECOL FIELD doku->datum      WIDTH 5  HEADER "Datum"      PARENT oBrowse9  ID 'BROWSE9_3'
     DCBROWSECOL FIELD doku->zeit       WIDTH 5  HEADER "Zeit"       PARENT oBrowse9  ID 'BROWSE9_4'
     aoTabPage[nTab]:lockUpdate(.t.)
     DCREAD GUI PARENT aoTabPage[nTab] EXIT  OPTIONS GetOptions SAVE PARENT @oDialog
     DC_MergeGetLists(aGetList,GetList)
     aoTabPage[nTab]:lockUpdate(.f.)
     aTabs[nTab] := .t.
endif
init_tab("DOKU",oBrowse9)
PostAppEvent(xbeP_Keyboard,xbeK_CTRL_PGDN,,oBrowse9)
SetAppFocus(oBrowse9)
return .t.


Re: gotfocus for dc_tabpage

Posted: Wed Jan 08, 2014 8:58 am
by rdonnay
I can't see the problem from the code that you have posted. It may be something in the init_tab() function.

Re: gotfocus for dc_tabpage

Posted: Thu Jan 09, 2014 1:45 am
by Tom
Hi, Rudolf.

I ran into the same problem. Now I simply set a memvar and catch if the dialog building is already done or not:

Code: Select all

lDlgBuilt := .F.
bGotFocus := {||IF(!lDlgBuilt,(Build_t2(2,GetList,oBrowse),dc_getrefresh(aoTabMsg[2])),nil),lDlgBuilt:=.T.}
You may also use a get-/set-function for this.

Re: gotfocus for dc_tabpage

Posted: Thu Jan 09, 2014 2:25 am
by reganc
rdonnay wrote:I can't see the problem from the code that you have posted. It may be something in the init_tab() function.
Roger

I was checking the docs yesterday and noticed that you added a MERGECHILDREN clause to DCTABPAGE. Would that not work here?

Re: gotfocus for dc_tabpage

Posted: Thu Jan 09, 2014 8:42 am
by c-tec
Hello Tom,
so the problem with gotfocus is not only in my application. Thank you for the tip, I will try it.
If I have time, I try to make a small sample app to show the problem.
regards
Rudolf

Re: gotfocus for dc_tabpage

Posted: Fri Jan 10, 2014 12:10 am
by c-tec
Hello Tom,
found that the soulution does not work for me. The build_t functions create the getlist elements and set the focus for the table. If I call it only once, I cannot change the focus when changing to another master record. I already check this with my aTabs array if the getlistelements are already attached. So it is difficult to differ between the second call of getfocus to refresh the table scope.
I think I have to do this with checking the last time when the tabpage has got focus.
regards
Rudolf

Re: gotfocus for dc_tabpage

Posted: Fri Jan 10, 2014 12:43 am
by c-tec
Hello,
found a strange thing. When I insert a altd(), the program stops twice each gotfocus, if I insert a dcqdebug, it works correct and shows only once a message when the tabpage gets focus. Maybe this can help Roger to find the problem.
regards
Rudolf

Code: Select all

...
local bColor,oDialog
//altd()   // stop twice each gotfocus
//dcqdebug "go focus!" // called only once on each gotfocus
if !aTabs[nTab]

     @ .5,.5 DCSAY {||DP_KUNNAME} SAYHVCENTER FONT '12.Arial Bold' SAYSIZE SIZE_X - 22,1.4 PARENT aoTabStatic[nTab] COLOR GRA_CLR_YELLOW,GRA_CLR_DARKBLUE OBJECT aoTabMsg[nTab]

     @ 2.1,.5 DCBROWSE oBrowse9 PAR

Re: gotfocus for dc_tabpage

Posted: Fri Jan 10, 2014 2:36 am
by skiman
Hi,

I was wondering why i never noticed this, because I use about the same code in my application.

If I set a 'WTF' in the beginning of my 'buildget()', the function is only called once? Is this something that is started from a certain version?

Re: gotfocus for dc_tabpage

Posted: Fri Jan 10, 2014 4:11 am
by c-tec
Hello,
I think it was in all versions, I always noticed it as strange flickering in such dialogs, now I know that it is gotfocus
regards
Rudolf

Re: gotfocus for dc_tabpage

Posted: Fri Jan 10, 2014 5:25 am
by skiman
Hi Rudolf,

I doubt that the gotfocus is the cause.

I have the following:
...GOTFOCUS {|a,b,oTab| oTab:tofront(), BuildGets(aTabPages,1,GetList,aBuildGets,aApp,oDialog) }

FUNCTION BuildGets( aTabPages, i, aGetLst,aBuildGets,aApp,oDialog )
Local ...
WTF i
...

In buildgets I have a 'WTF i' as first line, and this is called only once.