Page 1 of 1
Cursor position after tget:setfocus()
Posted: Sat Jan 31, 2015 5:14 am
by fraxzi
Dear All,
I have a button get and working fine. I need to position the cursor at the end of tget test when receiving focus.
I tried with:
1. oGet:bGotFocus := {|| oGet:KeyDown(VK_END) }
2. oGet:bGotFocus := {|| oGet:oGet:end() }
3. oGet:bGotFocus := {|| oGet:Setpos( 10 ) } //assuming 10 is the lenght..
but unsuccessful..
can anybody help?
Re: Cursor position after tget:setfocus()
Posted: Sat Jan 31, 2015 1:07 pm
by D.Fernandez
Hi, this way it's working fine here.
REDEFINE GET oGetNom VAR cNombre ID 130 OF oDlgSub1 FONT oFont2
oGetNom:SetPos(20)
If it's after the button action, is the same way.
ACTION(LoQueSea(), oGetNom:SetPos(20), oGetnom:Refresh())...
Saludos
Re: Cursor position after tget:setfocus()
Posted: Sun Feb 01, 2015 7:54 am
by Antonio Linares
Frances,
Try with:
oGet:bGotFocus := {|| oGet:Setpos( 9 ) }
Re: Cursor position after tget:setfocus()
Posted: Mon Feb 02, 2015 12:26 am
by fraxzi
Hi Antonio,
I already tried it... all not working.
When user opens a dialog with get (with text on it) the cursor should be position on the last character so typing is continuous. But with TGET the cursor
is always at the beginning.. I even set oGet:Keydown(VK_END) but still not working..
Re: Cursor position after tget:setfocus()
Posted: Mon Feb 02, 2015 12:27 am
by fraxzi
Hi Ruben,
oGet:Refresh() invokes oGet:GoHome() which always position the cursor to 1.
Re: Cursor position after tget:setfocus()
Posted: Mon Feb 02, 2015 9:38 am
by Enrico Maria Giordano
Frances,
this is a working sample:
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL oGet1, oGet2
LOCAL cVar1 := PADR( "This is a test", 35 )
LOCAL cVar2 := PADR( "This is a test", 35 )
DEFINE DIALOG oDlg;
SIZE 800, 600
@ 1, 1 GET oGet1 VAR cVar1 OF oDlg
oGet1:bGotFocus = { || oGet1:SetPos( Len( RTrim( cVar1 ) ) + 1 ) }
@ 3, 1 GET oGet2 VAR cVar2 OF oDlg
oGet2:bGotFocus = { || oGet2:SetPos( Len( RTrim( cVar2 ) ) + 1 ) }
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
EMG
Re: Cursor position after tget:setfocus()
Posted: Mon Feb 02, 2015 11:59 pm
by fraxzi
Hi Enrico,
This is what it needs to be done. the get in oBar fails..
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL oGet
LOCAL cVar := PADR( "This is a test", 35 )
DEFINE DIALOG oDlg;
SIZE 800, 600
@ 5, 1 GET oGet VAR cVar OF oDlg;
picture "@!";
bitmap '';
action msginfo('1')
oGet:bGotFocus = { || oGet:SetPos( Len( RTrim( cVar ) ) + 1 ) } //works perfectly with Enrico's example
ACTIVATE DIALOG oDlg CENTER;
ON INIT uDlgBar( oDlg );
ON PAINT oDlg:oBar:aControls[1]:SetFocus()
RETURN NIL
STATIC FUNCTION uDlgBar( oDlg )
LOCAL oBar, oGet
LOCAL cVar := PADR( "This is a test", 35 )
DEFINE BUTTONBAR oBar SIZE 28, 28 OF oDlg TOP 3D 2010
@ 1, 1 GET oGet VAR cVar OF oBar;
picture "@!";
bitmap '';
action msginfo('1')
oGet:bGotFocus = { || oGet:SetPos( Len( RTrim( cVar ) ) + 1 ) } //epic fail...
RETURN
Re: Cursor position after tget:setfocus()
Posted: Tue Feb 03, 2015 9:05 am
by Enrico Maria Giordano
Frances,
Code: Select all | Expand
oGet:bGotFocus = { || SysRefresh(), oGet:SetPos( Len( RTrim( cVar ) ) + 1 ) } //now works!
EMG
Re: Cursor position after tget:setfocus()
Posted: Wed Feb 04, 2015 3:33 am
by fraxzi
Enrico,
OMG... I never thought of Sysrefresh() on this situation. I thought it was a bug somewhere..
Thanks man!