Page 1 of 2

Focus oWnd

Posted: Fri Dec 23, 2005 3:27 pm
by Otto
I have a window with oGets, oSays and other controls.

I would like to control the input with:

oWnd:bkeyChar :={|nKey|iif( nKey == K_LEFT, msginfo("TASTE") )}

But after the first keystroke or if I insert some text in a get-field
I am not able to bring back focus to oWnd.

I tried oWnd:SetFocus() but with no success.

Also up-, down-, right-, left-key does not give back a value.

Thanks in advance
Otto

Re: Focus oWnd

Posted: Fri Dec 23, 2005 3:47 pm
by Enrico Maria Giordano
Try oGet:SetFocus() instead.

EMG

Posted: Fri Dec 23, 2005 4:48 pm
by Otto
Enrico, thank you for your help. But I don’t need focus on the get-field.
What I would like is to navigate the browser with the keys.
At the moment I only can use the mouse.
If you have time please see the screen capture.

If I enter something into the address I can’t pass focus back to the window itself.

Also cursor-key do not work.

www.atzwanger.com/invoice/for_emg.jpg

Thanks in advance
Otto

Posted: Fri Dec 23, 2005 5:04 pm
by Frank Demont
Try with SetActiveWindow(oWnd:hWnd)


Frank

Posted: Fri Dec 23, 2005 5:25 pm
by Otto
Thanks Frank,
I tried but with no success. Cursor remains in the get-field.
Otto

Posted: Fri Dec 23, 2005 5:40 pm
by Antonio Linares
Otto,

Try oGet:oJump := oWnd

Posted: Fri Dec 23, 2005 5:58 pm
by Otto
Antonio,

I put a small example on:

www.atzwanger.com/invoice/invoiceWithGet.zip

If you comment
// @ 1 , 1 GET oGet VAR cTest OF oWnd SIZE 75,17

keys work - up/down/left/right do not work.

With the getfield I only can use the mouse to navigate.
Regards
Otto

Posted: Fri Dec 23, 2005 7:04 pm
by Enrico Maria Giordano
Sorry but with your sample I can't use the arrow keys to navigate the browser at all. I can't even keep the focus off the get.

EMG

Posted: Fri Dec 23, 2005 7:31 pm
by Otto
Sorry Erico,

oWnd:bkeyChar :={|nKey|iif( nKey == K_ENTER , msginfo("ENTER"), msginfo(str(nKey)) )}

was only to show, that up/down/left/right don't return a value.

Change to:

oWnd:bkeyChar :={|nKey|iif( nKey == K_ENTER ,( oWnd:oVScroll():SetPos( nPos:=nPos+1),f_code()) ,)}

Comment the oGetLine and delete oGet:oJump := oWnd

than you can navigate down with the Enter-key.

On click shows the record .

Saluti
Otto

Posted: Fri Dec 23, 2005 10:11 pm
by Enrico Maria Giordano
Can you send me the fixed sample? I can't get it to work.

EMG

Posted: Fri Dec 23, 2005 10:44 pm
by Otto
www.atzwanger.com/invoice/invoiceforemg.zip

Hallo Enrico,
I uploaded the file.
Regards
Otto

Posted: Sat Dec 24, 2005 10:47 am
by Enrico Maria Giordano
Do I have to uncomment the GET? Can you explain what is exactly the problem?

EMG

Posted: Sat Dec 24, 2005 2:00 pm
by Otto
Enrico,
does the exe work on your side.
If yes you can scroll down with the enter-key or with a mouse-click on the scrollbar.
but if you have a getfield -for example to get the address - on the window too, focus is on the getfield and you can't navigate anymore with the keys.

I had a look at the wbrowse class maybe I have to make a control out of this source. But I never worked with classes.
I changed the wbrowse-class like this:
Inserted the method: ShowSomething
But there is no text on the screen.

I wish you a Merry Christmas.

Otto

METHOD ShowSomething() CLASS TWBrowse
local oWnd:= ::oWnd
@ 5,5 Say "TEST NEU" of oWnd

@ 15,15 Say "TEST NEU" of ::oWnd
@ 25,25 Say "TEST NEU" of oWnd


@ 35,35 Say "TEST NEU" of oWnd

@ 55,55 Say "TEST NEU" of oWnd

::oWnd:say( 0, 0, "TESTTSTSTSTSS" ,255,16777215,::oFont,.T.)
::oWnd:say( 50, 50, "TESTTSTSTSTSS",255,16777215,::oFont,.T.)

::oWnd:say( 5, 5, "TESTTSTSTSTSS" ,255,16777215,::oFont,.T.)
return nil

Posted: Sat Dec 24, 2005 2:06 pm
by Enrico Maria Giordano
Now I understood. No, you can't trap the arrow keys when the focus in on a GET, as far as I know.

EMG

Posted: Sat Dec 24, 2005 5:37 pm
by Antonio Linares
Otto,

If there is a control on the window, then it will have the focus, and the input events (keystrokes, mouse) will get routed to it.

If you need to edit on the screen, you may use a GET, but you need to destroy it, or to hide it, once you are finish with it, so the input events will not go through it.

Your code is ok. I guess you are close to get what you want.