Testget2 Behavoir

Testget2 Behavoir

Postby Rick Lipkin » Wed Jun 13, 2012 1:09 pm

To All

Is it possible to modify the behavior of the Get\Action to be able to accept the <enter> key to fire the action command as well as being able to click the button inside the Get.

I like the ability to have a button inside the Get, ( vs an external button ) but one of my software testers prefers a keyboard action vs taking their hands off the keyboard to reach over and click the mouse to fire the action.

Any advice would be appreciated.

Thanks
Rick Lipkin

Code: Select all  Expand view

#Include "FiveWin.Ch"


Function Main()
   Local oDlg
   Local oGet
   local cVar := space( 10 )

   DEFINE DIALOG oDlg from 0,0 to 400,400 pixel

   @ 15,15 get oGet var cVar picture "@!"  bitmap "..\bitmaps\chkyes.bmp" action( msginfo( "action" ) );
   size 120,12 of oDlg pixel
   oGet:lAdjustBtn := .t.  

   ACTIVATE DIALOG oDlg
 
 return nil

 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Testget2 Behavoir

Postby Armando » Wed Jun 13, 2012 3:56 pm

Rick:

Perhaps one way is usign the VALID clausule and not modify the class, here is my idea:

Code: Select all  Expand view

@ 15,15 get oGet var cVar picture "@!"  bitmap "..\bitmaps\chkyes.bmp" action( msginfo( "action" ) );
size 120,12 of oDlg pixel;
VALID MyValid(cVar);
oGet:lAdjustBtn := .t.  

FUNCTION MyValid(cVar)
IF EMPTY(ALLTRIM(cVar)) .AND.;
    GetAsyncKey(VK_ENTER)
    YourAction()   // It should be the same action for the button
ENDIF
RETURN(.F.)
 


Just an idea, regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3221
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Testget2 Behavoir

Postby ukoenig » Wed Jun 13, 2012 4:10 pm

Rick.
did You test :

oGet:bKeyDown:= {|nK| if( nK==VK_RETURN, ( msginfo( "action" ) ), ) }

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Testget2 Behavoir

Postby Rick Lipkin » Wed Jun 13, 2012 10:05 pm

Uwe

Your solution worked great .. I did have to use "old jedi mind trick" to pass the get parameter to my function .. here is the code .. note cInvSearch := oInvSearch:GetText() which allowed me to evaluate cInvSearch.

Thanks
Rick Lipkin


Code: Select all  Expand view

REDEFINE GET oInvSearch var cInvSearch ID 138 of oCust PICTURE "@!" BITMAP "find" ;
            action( _InvSearch( @cInvSearch,oLbxA,oRsCust,oInvSearch,oRsInvoice,oLbxB ) )
   oInvSearch:lAdjustBtn := .t.
   oInvSearch:bKeyDown:= {|nK| if( nK==VK_RETURN,_InvSearch( @cInvSearch,oLbxA,oRsCust,;
                                       oInvSearch,oRsInvoice,oLbxB,oLnameSearch ) , ) }


//--------------------
Static Func _InvSearch( cInvSearch,oBrwA,oRsCust,oInvSearch,oRsInvoice,oBrwB,oLnameSearch )

Local Saying,oRsInv,cSql,oErr,nInv,cCustomerId,cTest

oRsInvoice:Filter := "[Customer Id] = 'bogus'"
oBrwB:ReFresh()

cInvSearch := oInvSearch:GetText()

If empty(cInvSearch ) .or. cInvSearch = " "
   Saying := "Please enter an Invoice to Find"
   MsgInfo( Saying )
   oLnameSearch:SetFocus()
   Return(.t.)
Endif

nInv := val(alltrim(cInvSearch))

cSql := "Select [Repair Number], [Customer Id] From Invoice Where "
cSql += "[Repair Number] = "+ltrim(str(nInv))

oRsInv := TOleAuto():New( "ADODB.Recordset" )
oRsInv:CursorType     := 1        // opendkeyset
oRsInv:CursorLocation := 3        // local cache
oRsInv:LockType       := 3        // lockoportunistic

TRY
   oRsInv:Open( cSQL,xCONNECT )
CATCH oErr
   MsgInfo( "Error in Opening INVOICE table" )
   oLnameSearch:SetFocus()
   RETURN(.t.)
END TRY

If oRsInv:eof
   Saying := "Sorry .. Could not find Invoice "+alltrim(cInvSearch)
   MsgInfo( saying )
   cInvSearch := space(50)
   oInvSearch:ReFresh()
   oLnameSearch:SetFocus()
   Return(.t.)
Endif


cCustomerId := oRsInv:Fields("Customer Id"):Value
oRsCust:Filter := "[Customer Id] = '"+cCustomerId+"'"

oRsInv:CLose()
cInvSearch := space(50)
oInvSearch:ReFresh()

oBrwA:ReFresh()
oBrwA:SetFocus()

Return(.t.)


 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 49 guests