Page 1 of 1
on change for get
Posted: Fri May 18, 2007 8:42 pm
by patili
Hi
I HAVE A PROBLEM WITH THE CHANGE IN GET
I use a twbrose in which the database is indexed on the name
I want use a get which will change the scope of the browse
When i GET "M" it must scope the data beginning by "M"
and if if enter "A" after it must scope the data beginning by "MA" etc etc..
I use "redefine get.. on change (newscope, refresh)" and it didn't work
when i enter "M" the buffer is empty and the scope didn't change
i must enter the second letter and the the scope is working on the first letter
The change is always one letter late
Any idea? Thanks
Sorry for my bad english
Posted: Fri May 18, 2007 10:40 pm
by James Bott
Instead of bChange, use bPostKey. It is called like this in TGet.
Eval( ::bPostKey, Self, ::oGet:Buffer )
bChange is for use when you want to test the keystroke and either accept or reject it. If you return .t. from the codeblock the lastkey is accepted into the buffer, if you return .f. then the lastkey is not accepted.
bPostKey is eval'd after bChange so the lastkey will already be in the buffer.
James
Posted: Sat May 19, 2007 11:54 am
by patili
Thanks
but in my FW 2.1 i don't have this bpostkey method
It always return
Error description: Error Objects/6 No Exp. Method: TGET:_BPOSTKEY
How can i do?
Posted: Sat May 19, 2007 6:15 pm
by James Bott
Try this example.
James
--------------------
In order to use last char typed, let me suggest:
oGet:bChange:={|nKey| MyEval(oGet,nKey) }
Function MyEval(oGet,nKey)
Local cBuffer := oGet:oGet:Buffer
if nKey<>VK_RETURN
cBuffer := Stuff(cBuffer, ;
oGet:nPos,1,if(nKey=VK_BACK,'',chr(nKey))
// Now cBuffer contains the last char typed
// Do whatever here
return nil
Posted: Sun May 20, 2007 10:03 am
by patili
Many thanks James
The stuff function generate allways a fatal error on my computer, but
with your help i've found everything that work well
local nkey:=lastkey()
local filtre:=""
.
.
.
redefine get g1 var nm id 105 picture "!A" of rep
g1:bChange:={|nkey| MyEval(g1,nkey,oBrowse,@filtre) }
.
.
.
.
Function MyEval(oGet,nKey,oBrowse,filtre)
Local cBuffer := oGet:oGet:Buffer
cbuffer:=if(nkey=19,"",upper(chr(nkey))) // all fields are uppercase
filtre:=filtre+cbuffer
re->(sx_setscope(0,filtre)) // I use hypersix
re->(dbgotop())
oBrowse:refresh()
return nil
Thanks
Posted: Sun May 20, 2007 8:05 pm
by patili
And now it work in the two directions
Function MyEval(oGet,nKey,l1,filtre)
Local cBuffer := oGet:oGet:Buffer
if nkey=8
filtre:=substr(filtre,1,len(filtre)-1)
else
cbuffer:=upper(chr(nkey))
filtre:=filtre+cbuffer
endif
re->(sx_setscope(0,filtre))
re->(dbgotop())
l1:refresh()
return nil
Thank Thank James
Posted: Mon May 21, 2007 9:17 pm
by James Bott
I am glad to hear you got it working.
Regards,
James