Page 1 of 1

Browse doesn"t get focus

Posted: Sat Oct 02, 2010 8:57 pm
by Raymond Fischbach
Hello all,

I open a window that displays a browse.
I use the up and down arrows to skip the records in the browse, the selected record being white on blue while all other records are black on white.
There is a button (or I detect a keyboard key) that calls a sub function to do some data entry.
When I call this function, the selected record becomes white on grey (probably meaning that it is disabled).
When I come back from the sub function, the record stays disabled (white on grey).
If I use the scroll bar, there is no problem, the focus goes to the next (previous) record and it is enabled (white on blue).

The problem is when I want to skip with the arrow keys. I need to pess this key a few but variable number of times before it seems recognized.

How can I change the program so that the record is enabled when returning from the sub function ?

The following code is an extract of a more complex routine:

Code: Select all

   iif(nKey == Asc("3"),;
             (nEss := oF10b:ESSENCE,;
              iif (cMethode == "M" .AND.;
                   (nEss == 41 .OR. nEss == 42 .OR. nEss == 150 .OR. nEss == 151),;
                   cRet := "P",cRet := cMethode),;
              DetAddSel(aFichiers,Str(nEss),Str(oF10b:SOUS_CODE),cRet,"edit"),;
              oBrw:refresh(),;
              MsgInfo("*"),;
              oBrw:SetFocus()),;
 
Remark that MsgInfo("*") is executed but the browse doesn't seem to receive the focus.

Regards,
Raymond

Re: Browse doesn"t get focus

Posted: Wed Oct 06, 2010 6:28 am
by Antonio Linares
Raymond,

Try not to call oBrw:refresh() and see if that makes a difference, thanks

Re: Browse doesn"t get focus

Posted: Wed Oct 06, 2010 8:30 am
by Raymond Fischbach
Hi Antonio,

I have an answer, a workaround and maybe an explanation.

Explanation:
It seems that the function DetAddSel() is executed in another thread. Then the function is called and immediately the following statements are executed. Then the browse is active again, the new window is also started but it is covered by the browse.

Workarounds:
The one I have used is to add oBrw as a parameter to DetAddSel() and to move the refresh in that function just before leaving:

Code: Select all

oBrw:refresh()
oBrw:SetFocus()
 
Another possibility (I think but not tested) is to use pass oWnd as a parameter to DetAddSel and to use the clause "OF oWnd" when creating the new window. I suppose that then this new window will be modal.

Concerning your suggestion, I tried all possibilities but the record always remains disabled. This is not a problem if you use the touchscreen because as soon as you touch the screen, the browse regains the focus but the users of this program must use the keyboard.

Regards,
Raymond