on change for get

Post Reply
User avatar
patili
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

on change for get

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
patili
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Post 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?
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
patili
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Post 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
User avatar
patili
Posts: 98
Joined: Mon Jan 23, 2006 9:34 am
Location: LE CREUSOT FRANCE

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

I am glad to hear you got it working.

Regards,
James
Post Reply