FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour SetFocus problem
Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Fri Feb 24, 2006 09:11 AM
With this little example you can see that if I push "OK" button with mouse all works, if I push "ALT O" on keyboard all works, if I focus on "OK" and push "SPACE BAR" all works, but if I push "RETURN", focus goes on next control instead in "address".
I have FWH 2.7 feb 2006

Thank in advance
Gianni

#include "FiveWin.ch"

function Main()
   local oDlg
   local lFivePro  := .T.
   local lDialog   := .T.
   local lObjects  := .F.
   local nNivel    := 1
   local cName     := SPACE( 10 )
   local cAddress  := SPACE( 30 )
   local oBtn, oGet1, oGet2

   DEFINE DIALOG oDlg FROM 8, 2 TO 25, 50 TITLE "SetFocus test"

   @ 1,  1 SAY "&Name:" OF oDlg
   @ 1,  6 GET oGet1 VAR cName OF oDlg
   @ 2,  1 SAY "&Address:" OF oDlg
   @ 2,  6 GET oGet2 VAR cAddress OF oDlg

   @ 3,  1 TO 7, 8 LABEL "&Products" OF oDlg
   @ 4,  2 CHECKBOX lFivePro PROMPT "&FivePro" OF oDlg
   @ 5,  2 CHECKBOX lDialog  PROMPT "&Dialog"  OF oDlg
   @ 6,  2 CHECKBOX lObjects PROMPT "O&bjects" OF oDlg

   @ 3,  9 TO 7, 17 LABEL "&Nivel" OF oDlg
   @ 4,  9 RADIO nNivel PROMPT "&Novice", "A&vanced", "&Expert" OF oDlg

   @ 6,  3 BUTTON oBtn PROMPT "&Ok"  OF oDlg SIZE 50, 12 ACTION (oGet2:ctext("OK ACTION RUN ON " + TIME()),oGet2:SetFocus()) DEFAULT

   @ 6, 15 BUTTON "&Cancel" OF oDlg SIZE 50, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

return nil
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: SetFocus problem
Posted: Fri Feb 24, 2006 10:36 AM
Try this:

@ 6,  3 BUTTON oBtn PROMPT "&Ok"  OF oDlg SIZE 50, 12 ACTION (oGet2:ctext("OK ACTION RUN ON " + TIME()), oGet2:PostMsg(WM_SETFOCUS)) DEFAULT


EMG
Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Fri Feb 24, 2006 11:19 AM

Thank for answer but don't works. With "POSTMSG(WM_SETFOCUS)" it makes something strange, because I see the cursor in the get but the "real" focus is in some other control.

Regards
Gianni

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
SetFocus problem
Posted: Fri Feb 24, 2006 01:15 PM

Try adding a oGet2:refresh() after the oGet2:setFocus().

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Fri Feb 24, 2006 03:38 PM

James,
many thank for reply but still don't works.

Regards
Gianni

Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
SetFocus problem
Posted: Fri Feb 24, 2006 05:07 PM

I think you need to add an :oJump
Try this:

@ 6, 3 BUTTON oBtn PROMPT "&Ok" OF oDlg SIZE 50, 12 ACTION (oGet2:ctext("OK ACTION RUN ON " + TIME()),oBtn:oJump := oGet2, oGet2:SetFocus()) DEFAULT

Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Fri Feb 24, 2006 05:15 PM

Gale,
thanks but don't works.

Regards
Gianni

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
SetFocus problem
Posted: Fri Feb 24, 2006 08:52 PM
Try this:

   @ 6,  3 BUTTON oBtn PROMPT "&Ok"  OF oDlg SIZE 50, 12 ACTION ( oGet2:ctext("OK ACTION RUN ON " + TIME()),;
                                                                  oBtn:SetFocus(),;
                                                                  SysRefresh(),;
                                                                  oGet2:SetFocus() ) DEFAULT


EMG
Posts: 48
Joined: Tue Dec 27, 2005 12:40 PM
Try this
Posted: Sat Feb 25, 2006 01:00 AM

Change
@ 2, 6 GET oGet2 VAR cAddress OF oDlg

to

@ 2, 6 GET oGet2 VAR cAddress OF oDlg UPDATE

and
@ 6, 3 BUTTON oBtn PROMPT "&Ok" OF oDlg SIZE 50, 12 ACTION (oGet2:ctext("OK ACTION RUN ON " + TIME()),oGet2:SetFocus()) DEFAULT

to

@ 6, 3 BUTTON oBtn PROMPT "&Ok" OF oDlg SIZE 50, 12 ACTION (cAddress := "OK ACTION RUN ON " + TIME(),oGet2:Refresh(), oGet2:SetFocus(), Sysrefresh()) DEFAULT

Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Sat Feb 25, 2006 09:45 AM

Grumpy,
thanks you too but don't works.

Regards
Gianni

Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Sat Feb 25, 2006 09:55 AM

EnricoMaria,
thanks you, know it almost works!
There is still only one case that don't works and it is when I push "RETURN" when focus is already on "OK" button. In this case focus goes on "CANCEL" button!!! :shock:
Don't you think is a FWH bug? I think that even your code almost works, it is a work around.

Regards
Gianni

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
SetFocus problem
Posted: Sat Feb 25, 2006 10:02 AM

No, I think that it is your design that is wrong.

EMG

Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Sat Feb 25, 2006 04:34 PM

EMG,
I don't understand what's wrong in my design.
I only need that a get take focus after a keyboard RETURN.
What's wrong in it?
SETFOCUS will be ignored when I use RETURN key. If I use another way ( mouse or SPACE or accelerator) all works. This different behaviour make me to think that it is a bug even my design was wrong.

Regards
Gianni

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
SetFocus problem
Posted: Sat Feb 25, 2006 10:18 PM
Sorry, I would have to say "perhaps". Anyway, this is a sample that solves the last problem:

   @ 6,  3 BUTTON oBtn PROMPT "&Ok"  OF oDlg SIZE 50, 12 ACTION ( oGet2:ctext("OK ACTION RUN ON " + TIME()),;
                                                                  oGet2:SetFocus(),;
                                                                  SysRefresh(),;
                                                                  oGet2:SetFocus() ) DEFAULT


EMG
Posts: 30
Joined: Fri Oct 07, 2005 06:58 AM
SetFocus problem
Posted: Mon Feb 27, 2006 08:47 AM

EMG,
many thanks, now it works!!!

Gianni