How to calc. Restlength of a GET-field during Edit (solved)

How to calc. Restlength of a GET-field during Edit (solved)

Postby ukoenig » Sat Mar 20, 2010 11:00 am

Hello

in some Situations, I have to show the Restlength of a Getfield during Input.
With Inputs like "Ijl", the User is confused : There is still Space inside the Get, why I cannot write anymore !
It works, but only with Return. I have to control during Edit without Return.
Is there another Solution possible ?

// GetField-Len = 100
REDEFINE GET oSyntax1 VAR cSyntax ID 120 OF oDlg UPDATE ;
VALID ( ( oSyntax1:Refresh(), nSyntax := 100 - LEN( Alltrim( cSyntax ) ), oSyntax2:Refresh() ) , .T. )

REDEFINE SAY oSyntax2 VAR nSyntax ID 125 FONT oButtFont COLOR 128 OF oDlg UPDATE

The Screenshot shows the Problem.
A Get with Len 100 and Input of 10 different Chars :

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Sun Mar 21, 2010 1:28 am, edited 3 times in total.
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: How to control Restlength of a Get during Edit ?

Postby anserkk » Sat Mar 20, 2010 11:18 am

What about oSyntax1:bKeyDown ?

Regards
Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: How to control Restlength of a GET-field during Edit ?

Postby ukoenig » Sat Mar 20, 2010 12:02 pm

It works using a Key-Counter, but I need the trimmed Restlength of the Get during Input.
A oGet:Sysrefresh() doesn't work to show => LEN(TRIM(cSyntax))
What happens, the user includes something from the Clipboard ?

nCount := 0
// GetField-Len = 100
REDEFINE GET oSyntax1 VAR cSyntax ID 120 OF oDlg UPDATE
oSyntax1:bKeyDown := { | nKey, nFlags | ;
nCount++, ;
nSyntax := 100 - nCount, ;
oSyntax2:Refresh() }

REDEFINE SAY oSyntax2 VAR nSyntax ID 125 FONT oButtFont COLOR 128 OF oDlg UPDATE

Best Regards
Uwe :lol:
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: How to control Restlength of a GET-field during Edit ?

Postby nageswaragunupudi » Sat Mar 20, 2010 12:22 pm

Please try this logic
Code: Select all  Expand view
func test()

   local odlg, cVar, oGet, oSay, nRest

   cVar     := PadR( 'Hello', 100 )
   nRest    := Len( cVar ) - Len( Trim( cVar ) )

   DEFINE DIALOG oDlg SIZE 500,100 PIXEL

   @  5,  5 GET oGet VAR cVar SIZE 200,10 PIXEL OF oDlg
   oGet:bChange :=  { || nRest := Len( cVar ) - Len( Trim( oGet:cText ) ), oSay:Refresh()  }

   @  5,210 SAY oSay PROMPT nRest PICTURE '999' ;
      SIZE 30,10 PIXEL OF oDlg RIGHT


   ACTIVATE DIALOG oDlg CENTERED

return nil
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to control Restlength of a GET-field during Edit ?

Postby ukoenig » Sat Mar 20, 2010 12:46 pm

Thank You very much,

Your Solution works perfect, but I noticed :
including Text from Clipboard, the Chars are not counted.
It means : in case pasting something from Clipboard, the length must be added to the Counter.
It is not the normal Situation.
The Main-problem is solved with Your Solution : counting from Keyboard.

Best Regards
Uwe :lol:
Last edited by ukoenig on Sat Mar 20, 2010 1:03 pm, edited 1 time in total.
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: How to control Restlength of a GET-field during Edit ?

Postby nageswaragunupudi » Sat Mar 20, 2010 12:57 pm

ukoenig wrote:Thank You very much,

Your Solution works perfect, but I noticed :
including Text from Clipboard, the Chars are not counted.
It means : in case pasting something from Clipboard, the length must be added to the Counter.
It is not the normal Situation. T
he Main-problem is solved with Your Solution : counting from Keyboard.

Best Regards
Uwe :lol:

If text is pasted by pressing Ctrl-V, it is working.
If text is pasted by Mouse right click and paste it is not working.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to control Restlength of a GET-field during Edit ?

Postby nageswaragunupudi » Sat Mar 20, 2010 1:21 pm

Mr Uwe

If you like u may make the modification to TGet.Prg:

In the method HandleEvent() of TGet class, you find ::oGet:Assign three times. After each occurance of ::oGet:Assign(), please add the following three lines:
Code: Select all  Expand view
          if ::bChange != nil
              Eval( ::bChange, ,, Self )
           endif
 

Now this works for all cases of pasting
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to control Restlength of a GET-field during Edit ?

Postby ukoenig » Sat Mar 20, 2010 1:59 pm

Mr Rao,

Thank You very much for Your Help,
Yes, the Clipboard was added with the Mouse.
I used Your Example and with the change of Class TGet, the Clipboard-Problem will be solved.
I still noticed : Spaces are not counted, because of : - Len( Trim( oSyntax1:cText )
A small change is needed, to count Spaces as well.
Code: Select all  Expand view

// GetField-Len = 100
nSpace := 0
REDEFINE GET oSyntax1 VAR cSyntax  ID 120 OF oDlg  UPDATE
oSyntax1:bChange :=  { |nKey| ;
IIF( nKey <> 32 .and. nKey <> 8, nSpace := 0, NIL ), ; // no Blanc or Backspace
IIF( nKey = 32 .and. nKey <> 8, nSpace++, NIL ), ; // only Blanc
IIF( nKey = 8 .and. nSpace > 0, nSpace--, NIL ), ; // Backspace and Blanc-Counter > 0
nSyntax := Len( cSyntax ) - Len( Trim( oSyntax1:cText ) ) - nSpace, oSyntax2:Refresh() }

REDEFINE SAY oSyntax2 VAR nSyntax ID 125 FONT oButtFont COLOR 128 PICTURE "999" OF oDlg UPDATE
 


I think, it is a very useful Help for a User, for often used Get-fields.
In the Past : the User writes some Text. He noticed : the Text is to long.
Next he has to check the Input, to shorten something.

Image

Best Regards
Uwe :lol:
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: How to calc. Restlength of a GET-field during Edit (solved)

Postby Silvio » Sun Mar 21, 2010 8:34 pm

have you a test with GET MEMO ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: karinha and 20 guests