Picture "@K" and selectall()

Picture "@K" and selectall()

Postby Gale FORd » Mon Sep 26, 2011 9:31 pm

In order to emulate the "@K" feature in clipper I have been adding a bGotfocus codeblock to each get like below.
::oShipCons:bGotFocus := { || ::oShipCons:PostMsg( WM_KEYDOWN, VK_HOME ), ::oShipCons:selectall(), ::oShipCons:PostMsg( WM_KEYUP ) }

I think it would be better to have "@K" supported by the tget class. So I added 3 lines of code to tget.prg and it seems to work pretty good.
Can this be added to the regular class?

around line 1516 in tget.prg method gotfocus()
if ! Empty( ::cPicture ) .and. "K" $ ::cPicture
::SelectAll()
endif

here is the entire method
Code: Select all  Expand view

METHOD GotFocus( hCtlLost ) CLASS TGet

    ::lFocused = .t.

    #ifdef __XHARBOUR__
       ::oGet:VarGet()
    #endif

    #ifdef __XPP__
       DEFAULT ::lClrFocus := .F.
    #endif

    if ! Empty( ::cPicture ) .and. ::oGet:Type == "N"
       ::oGet:Picture := StrTran( ::cPicture, ",", "" )
    endif

    if ! ::lDrag
       ::oGet:KillFocus()   // to properly initialize internal status
       ::oGet:SetFocus()
       if Upper( ::oWnd:ClassName() ) == "TCOMBOBOX"
          ::oGet:Buffer := ::oGet:Original
       endif
       if ::lClrFocus
          ::nOldClrPane = ::nClrPane
          ::SetColor( ::nClrText,;
              If( ValType( ::nClrFocus ) == "B", Eval( ::nClrFocus ), ::nClrFocus ) )
       endif
       ::DispText()
       if ::oGet:Type $ "DN" .or. ::oGet:Pos != 1 // 28/06/05 AL
          ::nPos := ::oGet:Pos // 1   28/06/05 AL
       endif
       ::oGet:Pos := ::nPos
       ::SetPos( ::nPos )
       CallWindowProc( ::nOldProc, ::hWnd, WM_SETFOCUS )
       if Set( _SET_INSERT )
          DestroyCaret()
          CreateCaret( ::hWnd, 0, 6, ::nGetChrHeight() - 1 )
          ShowCaret( ::hWnd )
       endif
       // Here is the "@K" modification
       if ! Empty( ::cPicture ) .and. "K" $ ::cPicture
         ::SelectAll()
       endif
    else
       HideCaret( ::hWnd )
    endif

    Super:GotFocus( hCtlLost )

return 0

 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Picture "@K" and selectall()

Postby Gale FORd » Tue Sep 27, 2011 2:17 pm

I had to modify this some. I moved the code after the Super:GotFocus( hCtlLost ) and added a check if the control was readonly
This is around line 1521 in tget.prg
Code: Select all  Expand view

    Super:GotFocus( hCtlLost )
       // GDF Modified 09/27/2011
       if ! Empty( ::cPicture ) .and. "K" $ ::cPicture .and. ! ::lReadOnly
         ::SelectAll()
       endif
 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Picture "@K" and selectall()

Postby James Bott » Tue Sep 27, 2011 11:42 pm

Gale,

Back in 2006 I did a similar modification for @K. I changed the GoHome() method in TGet. Below is my change. You might want to try it and compare to yours.

I note that in FWH 10.08 still has the same original GoHome() method as the one I modified in 2006.

Regards,
James


Code: Select all  Expand view
method GoHome() class TGet

   ::oGet:Home()
   //if ::oGet:Type == "N"  // flag to clear buffer if typing is detected
   if ::oGet:Type == "N" .or. "K" $ upper(::oGet:Picture)   // J Bott
      ::oGet:Clear := .t.
   endif
   ::SetPos(::oGet:Pos)

return Self
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Picture "@K" and selectall()

Postby Gale FORd » Wed Sep 28, 2011 4:55 am

I did not notice the picture "@K" working. The modification you did will allow the contents of the get to be erased with the next key pressed?
The users seem to like the selectall() visual indication that the contents will be erased when a key is pressed.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Marc Venken and 130 guests