Page 1 of 1

Clear Typehead

PostPosted: Thu Aug 02, 2007 2:35 pm
by Patricio Avalos Aguirre
Estimados

tengo un browse el cual al presionar la tecla ENTER entra a un dialogo
pero resulta que dentro del dialogo si se presiona el boton salir vuelve a ejecutarse nuevamente, como si hubiera presionado enter nuevamente

mi pregunta es como limpiar el buffer del teclado...

lo estoy haciendo asi...

Code: Select all  Expand view
oBrw:bKeyDown  := { |nKey| iif( nKey = 13, (ABM( aDbf, .F., oBrw, lSoloLectura ), SysRefresh() ), NIL ) }


desde ya gracias

PostPosted: Thu Aug 02, 2007 2:46 pm
by jrestojeda
oBrw:bKeyDown :={|nkey,nFlag| IF(nKey=13, ABMBancos(oDbf,oBrw,oDlg,nKey,oWnd), )}

Prueba lo siguiente.
Saludos, Esteban.

PostPosted: Thu Aug 02, 2007 3:06 pm
by Patricio Avalos Aguirre
gracias por responder pero igual sigue el problema

por ahora lo he dejado en comentario, solo con el dblclick del mouse

viendo post antiguo creo que no existe una solucion...



saludos..

PostPosted: Thu Aug 02, 2007 3:18 pm
by jrestojeda
No te olvides de que dentro de tu funcion ABM debes refrescar el oBrw y ponerle el foco justo antes de terminar.

Es decir:

oBrw:bKeyDown :={|nkey,nFlag| IF(nKey=13, ABMBancos(oDbf,oBrw,oDlg,nKey,oWnd), )}

...
...

//
Function ABMBancos(oDbf,oBrw,oDlg,nKey,oWnd)

...
...

oBrw:Refresh()
oBrw:SetFocus()
Return nil
//

PostPosted: Thu Aug 02, 2007 4:00 pm
by Francisco Horta
a mi me va bien,
prueba a usar:
nKey==VK_RETURN
en lugar de:
nKey=13
y no olvides cuando cierras el dialogo poner el foco en el browse
salu2
paco

PostPosted: Thu Aug 02, 2007 4:02 pm
by Patricio Avalos Aguirre
Asi tengo el final del la funcion ABM, igual el problem..! :-(

Code: Select all  Expand view
ACTIVATE DIALOG oDlg CENTERED ON PAINT iif( valtype( oBrw ) = "O", oBrw:SetFocus(),)

dbART:OrdSetFocus( cOldkey )
dbART:GoTo( aRegi[1] )
dbFAM:Goto( aRegi[2] )
dbCLA:Goto( aRegi[3] )
aEval( aDbf, { |x| x:Load() } )
if Valtype( oBrw ) = "O"
   oBrw:Refresh()
   oBrw:SetFocus()
endif

RETURN( .T. )
//----------------------------------------------------------------------------//

PostPosted: Thu Aug 02, 2007 4:11 pm
by jrestojeda
Una pregunta:

Como estás defiendo el Boton para salir?

PostPosted: Thu Aug 02, 2007 4:48 pm
by Patricio Avalos Aguirre
Code: Select all  Expand view
REDEFINE BUTTON ID 716 OF oDlg   ;
            ACTION oDlg:End()    ;
         CANCEL


adjunto un pequeño video,..

http://www.bigupload.com/d=77487AC1

saludos

PostPosted: Thu Aug 02, 2007 5:07 pm
by jrestojeda
Mira aparentemente está todo bien.
A mi me funciona perfecto y lo único que se me ocurre es que tu proceso no esté ingresando nunca al if que utilizas para poner el foco al salir de la funcion.

if Valtype( oBrw ) = "O"
oBrw:Refresh()
oBrw:SetFocus()
endif

Prueba poniendo un MsgInfo() dentro del If para ver si está ingresando.
La verdad es lo único que se me ocurre. Debería funcionar sin ningún problema.
Saludos, Esteban

PostPosted: Thu Aug 02, 2007 8:00 pm
by Patricio Avalos Aguirre
Encontre el problema

Mirando el metodo keydown() de la clase twbrowse

Code: Select all  Expand view
METHOD KeyDown( nKey, nFlags ) CLASS TWBrowse

   local lRefresh

if ::bKeyDown != nil
    Eval( ::bKeyDown, nKey, nFlags, Self )
endif

do case
   case nKey == VK_UP
       ::cBuffer:= ""
       ::GoUp()
bla...bla...


si que comente

Code: Select all  Expand view
/*
if ::bKeyDown != nil
    Eval( ::bKeyDown, nKey, nFlags, Self )
endif
*/


o bien podria dejarlo al final, bueno vere cual seria la mejor opcion

muchas gracias a todos los que respondieron

Saludos...

PostPosted: Thu Aug 02, 2007 8:27 pm
by Francisco Horta
patricio este el metodo keydown que tengo en la clase, probablemente tienes la ver no mas actual de la 17
METHOD KeyDown( nKey, nFlags ) CLASS TWBrowse

local lRefresh

do case
case nKey == VK_UP
::cBuffer:= ""
::GoUp()

case nKey == VK_DOWN
::cBuffer:= ""
::GoDown()

case nKey == VK_LEFT
::cBuffer:= ""
If ::GoLeft()
::Refresh()
EndIf

case nKey == VK_RIGHT
::cBuffer:= ""
If ::GoRight()
::Refresh()
EndIf

case nKey == VK_HOME
::cBuffer:= ""
::GoTop()

case nKey == VK_END
::cBuffer:= ""
::GoBottom()

case nKey == VK_PRIOR
::cBuffer:= ""
if GetKeyState( VK_CONTROL )
::GoTop()
else
::PageUp()
endif

case nKey == VK_NEXT
::cBuffer:= ""
if GetKeyState( VK_CONTROL )
::GoBottom()
else
::PageDown()
endif

case ::bSeek != Nil .and. !::lWorking .and. nKey == VK_BACK
::lWorking:= .T.
::cBuffer := SubStr( ::cBuffer, 1, Len(::cBuffer) - 1 )
if "L" $ ValType( lRefresh:= Eval( ::bSeek ) ) .and. lRefresh
::nRowPos:= Max( Min( ::nLen, ::nRowCount ), 1 )
::Refresh()
endif
::lWorking:= .F.

case ::bSeek != Nil .and. ( nKey == VK_SHIFT .or. nKey >= 32 )
// No Hacer nada !!!, pero respetar el Super.
Super:KeyDown( nKey, nFlags )

otherwise
::cBuffer:= ""
If( ::bSeek != Nil .and. ::bUpdateBuffer != Nil, Eval( ::bUpdateBuffer ), )

// Posibilidad de efectuar acciones con TABs 13/05/04
if nKey == VK_TAB .and. ::bKeyDown != nil
Eval( ::bKeyDown, nKey, nFlags )
endif

return Super:KeyDown( nKey, nFlags )
endcase

If( ::bSeek != Nil .and. ::bUpdateBuffer != Nil, Eval( ::bUpdateBuffer ), )

return 0
salu2
paco