SetFocus problem

SetFocus problem

Postby Gianni » Fri Feb 24, 2006 9: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

Code: Select all  Expand view  RUN
#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
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Re: SetFocus problem

Postby Enrico Maria Giordano » Fri Feb 24, 2006 10:36 am

Try this:

Code: Select all  Expand view  RUN
@ 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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gianni » 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
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Postby James Bott » Fri Feb 24, 2006 1:15 pm

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

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Gianni » Fri Feb 24, 2006 3:38 pm

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

Regards
Gianni
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Postby Gale FORd » Fri Feb 24, 2006 5: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
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Gianni » Fri Feb 24, 2006 5:15 pm

Gale,
thanks but don't works.

Regards
Gianni
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Postby Enrico Maria Giordano » Fri Feb 24, 2006 8:52 pm

Try this:

Code: Select all  Expand view  RUN
   @ 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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Try this

Postby grumpy » Sat Feb 25, 2006 1: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
grumpy
 
Posts: 48
Joined: Tue Dec 27, 2005 12:40 pm
Location: Australia

Postby Gianni » Sat Feb 25, 2006 9:45 am

Grumpy,
thanks you too but don't works.

Regards
Gianni
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Postby Gianni » Sat Feb 25, 2006 9: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
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Postby Enrico Maria Giordano » Sat Feb 25, 2006 10:02 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gianni » Sat Feb 25, 2006 4: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
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Postby Enrico Maria Giordano » Sat Feb 25, 2006 10:18 pm

Sorry, I would have to say "perhaps". Anyway, this is a sample that solves the last problem:

Code: Select all  Expand view  RUN
   @ 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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Gianni » Mon Feb 27, 2006 8:47 am

EMG,
many thanks, now it works!!!

Gianni
Gianni
 
Posts: 30
Joined: Fri Oct 07, 2005 6:58 am

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 59 guests