Page 1 of 1

"@K" clausule : Clipper/xharbour <->FWH

Posted: Sun Nov 01, 2009 11:19 am
by demont frank
Hello,

A few days ago i started a thread regarding @K clausule in GET . I made some tests :

1) In clipper/Xharbour it works when a input field receive focus , the cursor will be on the first character
A field can become focus with the keyboard (ENTER , TAB) or with the mouse
Note that when we click on the second character from a field , first the field receive focus (cursor on the first character) , and we have to click twice to set the cursor on the second character.

This means that the field will not be erased when we set the cursor on the first character with the left arrow , or with the mouse when the cursor was in the field.
So we can avoid erasing by using left and right arrow before changing the first character

Important is also that we can press Ctrl-U to undo the changes from the input , the cursor is set on the first character and the K-clausule will be active again

2) In fwh the K-clausule works only when the input-field has become focus with the keyboard. Moving in the field with arrow or mouse deactivates the k-clausule (as in clipper) , we have no Ctrl-U to use , can only reactivate by leaving and reentering the field

It is not clear where we have to look in the FWH-code to change the setfocus method , so that it also works with the mouse.
Next method in tget seems to have as goal to reactivate the k-Clausule , but doesn't work :

Code: Select all

METHOD GoHome() CLASS TGet
   ::oGet:Home()
  if ::oGet:Type == "N" .or. "K" $ upper(::oGet:Picture) // flag to clear buffer if typing is detected , James Bott
      ::oGet:Clear := .t.
   endif
::SetPos( ::oGet:Pos )
return Self
 
Using bKeydown from the get , i have a solution , at least for me , using Ctrl-Home or Ctrl-U to reactivate K-clausule , Ctrl-Del to delete:

Code: Select all


oGet:bKeyDown := {|nKey|IIF(GetKeyState(VK_CONTROL),(IIF(nKey==VK_DELETE,WisVeld(oGet),;
IIF(nKey==85,GetUndo(oGet),IIF(nKey==VK_HOME,oGet:Refresh(),)))),)}
PROC WisVeld(oGet)
******************
LOCAL x
IF oGet:oGet:Type=="C"
  x:= SPACE(LEN(oGet:Varget()))
ELSEIF oGet:oGet:Type=="N"
  x:= 0
ELSEIF oGet:oGet:Type=="D"
  x := CTOD("")
END
oGet:varput(x)
oGet:Refresh()
RETURN
********************************************
PROC GetUndo(oGet)
******************
oGet:Varput(oGet:oGet:Original)
oGet:Refresh()
RETURN
 

Re: "@K" clausule : Clipper/xharbour <->FWH

Posted: Mon Dec 07, 2009 10:26 am
by Antonio Linares
Frank,

If that code used from bKeyDown works as expected, then we could port it to Method KeyDown() in Class TGet so there is no need to set bKeyDown for it.

Do you have a small and self contained example to test this ? thanks

Re: "@K" clausule : Clipper/xharbour <->FWH

Posted: Tue Dec 08, 2009 11:42 am
by demont frank
Antonio Linares wrote:Frank,

Do you have a small and self contained example to test this ? thanks
Antonio ,

This code was proposed to activate "@K" clausule (again) in a input field , Giving a input field focus with the mouse.
After this thread , i found a solution , see http://forums.fivetechsupport.com/viewt ... =3&t=17219
Maybe you can reread the threads, only one change must be made in lButtondown from tget.prg to make "@K" clause to work also with the mouse :

Code: Select all

# ifdef FRANKDEMONT
      if ::bLClicked != nil
          Eval( ::bLClicked, nRow, nCol, nFlags, Self )
      endif
      IF ::nPos==1 .AND. HB_ISSTRING(::cPicture) .AND. "K" $ upper(::cPicture)
         ::Refresh() // Activates erasing get with first character
     END
# else
      if ::bLClicked != nil
         Eval( ::bLClicked )
      endif
# endif
 
There is still a difference with clipper , xharbour or windows(IEXPLORER) , in FW we can with one click go to a character in a inputfield , in the others we need two click. After the first click the cursor is set to the first character.

In method keydown i added :

Code: Select all

     # ifdef FRANKDEMONT
     if GetKeyState( VK_CONTROL )
       DO CASE
        Case nKey == VK_DELETE
           RETURN WisInpVeld(self)       // In TestSplit.prg
        Case nKey == VK_HOME
           ::Assign()
           ::Refresh()
           RETURN 0
        Case nKey == 85 // Ctrl-U
           ::Varput(::oGet:Original)
                       ::Refresh()
           RETURN 0
                    endcase
     endif
     # endif
 
This code is more tha a month active without problems
Maybe only Ctrl-U is usefull , while we usung it in clipper.
To test this, you need only a dialog with two Get's , one with a "@K" clausule , the other without.

Frank