Page 1 of 1

TGET Ignore VALID

PostPosted: Tue Dec 24, 2013 11:55 am
by MGA
Sr. Antonio, código abaixo demonstra que é possível ignorar o VALID de um GET pressionando VK_F3.

local oDlg, cTest := SPACE(20), oBut[2]

DEFINE DIALOG oDlg TITLE "VK_F3 ignore VALID"

odlg:bkeydown:={|nkey| if(nkey==VK_F3,oBut[1]:click(),)}

@ 1, 3 GET cTest picture "@!" valid .f.

@ 3, 5 BUTTON oBut[1] prompt "&Ok" SIZE 40, 12 ACTION MsgInfo( "Any action here. Ignore VALID problem!" )

@ 3, 16 BUTTON oBut[2] prompt "&Cancel" SIZE 40, 12 ACTION oDlg:End() cancel

ACTIVATE DIALOG oDlg CENTERED


Existe uma solução para este problema?

Re: TGET Ignore VALID

PostPosted: Thu Dec 26, 2013 4:06 pm
by Antonio Linares
Please try it this way:

@ 1, 3 GET oGet VAR cTest picture "@!" valid .f.

odlg:bkeydown:={|nkey| if(nkey==VK_F3 .and. oGet:lValid(),oBut[1]:click(),)}

Re: TGET Ignore VALID

PostPosted: Thu Dec 26, 2013 4:27 pm
by Ariel
Antonio,

El tema es si tenes mas de 1 control (GET), debes hacer eso x cada uno ?? Xq sino se dispara igual...

Salu2, Ariel.

Re: TGET Ignore VALID

PostPosted: Thu Dec 26, 2013 4:30 pm
by Antonio Linares
Se podría hacer:

odlg:bkeydown:={|nkey| if(nkey==VK_F3 .and. oWndFromHwnd( GetFocus() ):lValid(),oBut[1]:click(),)}

lo que no entiendo cual es la razón de asignar ese codeblock al diálogo.

Re: TGET Ignore VALID

PostPosted: Thu Dec 26, 2013 4:57 pm
by MGA
Senhor Antonio,

é possível uma alteração na classe TGET ou TBUTTON para evitar alteração no sistema inteiro?

Re: TGET Ignore VALID

PostPosted: Thu Dec 26, 2013 7:12 pm
by Antonio Linares
Please try this change in Class TButton in Method Click line 162 and let me know if it is fine for you:

Code: Select all  Expand view
     if ::bAction != nil .and. ::lValid()  // here !!!
         Eval( ::bAction, Self )
      endif

Re: TGET Ignore VALID

PostPosted: Fri Dec 27, 2013 10:57 am
by MGA
muito obrigado, vou testar e posto o resultado!

Re: TGET Ignore VALID

PostPosted: Fri Dec 27, 2013 1:14 pm
by MGA
Sr. Antonio,

Não funciona:

if ::bAction != nil .and. ::lValid() // here !!!
Eval( ::bAction, Self )
endif

:(

Re: TGET Ignore VALID

PostPosted: Fri Dec 27, 2013 2:10 pm
by Rick Lipkin
SGS

Forgive my spanish .. if you are trying to close a dialog without the valid firing try this ..

Code: Select all  Expand view

oBtn[2]:lCancel := .t.
 


Rick Lipkin

Re: TGET Ignore VALID

PostPosted: Fri Dec 27, 2013 2:55 pm
by cnavarro
SGS wrote:Sr. Antonio,

Não funciona:

if ::bAction != nil .and. ::lValid() // here !!!
Eval( ::bAction, Self )
endif

:(


Prueba asi:
Code: Select all  Expand view


#include "fivewin.ch"

Function Main()

local oDlg
local cTest := SPACE(20)
local oBut  := { , } //[2]
local oGet

DEFINE DIALOG oDlg TITLE "VK_F3 ignore VALID"

//oDlg:bKeydown := {| nkey | if( nkey == VK_F3, oBut[1]:click(), )}
oDlg:bKeydown := {| nkey | if( nkey == VK_F3, PulsaF3( oDlg, oBut ), )}

@ 1, 3 GET oGet VAR cTest picture "@!" valid ( .F. )

@ 3, 5 BUTTON oBut[1] prompt "&Ok" SIZE 40, 12 ACTION MsgInfo( "Any action here. Ignore VALID problem!" )

@ 3, 16 BUTTON oBut[2] prompt "&Cancel" SIZE 40, 12 ACTION oDlg:End() CANCEL

ACTIVATE DIALOG oDlg CENTERED

Return nil

//---------------------------------------------------

Function PulsaF3( oDlg, oBtt )

if oDlg:oCtlFocus:lValid()
   oBtt[1]:click()
else
   oDlg:oCtlFocus:SetFocus()
endif
Return nil

 

Re: TGET Ignore VALID

PostPosted: Fri Dec 27, 2013 7:40 pm
by cnavarro
Funciona igual si se modifica la Clase TWindow en el metodo KeyDown


Code: Select all  Expand view


METHOD KeyDown( nKey, nFlags ) CLASS TWindow

...../...

   if ::oWnd != nil .and. IsChild( ::oWnd:hWnd, ::hWnd )
     
       if ::oWnd:oCtlFocus:lValid()                // He añadido
         ::oWnd:KeyDown( nKey, nFlags )
      endif                                                  //
   endif

return nil

 

Re: TGET Ignore VALID

PostPosted: Tue Dec 31, 2013 12:19 am
by MGA
Muito obrigado, vou testar!