Cursor position after tget:setfocus()

Cursor position after tget:setfocus()

Postby fraxzi » Sat Jan 31, 2015 5:14 am

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?
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Cursor position after tget:setfocus()

Postby D.Fernandez » Sat Jan 31, 2015 1:07 pm

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
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 472
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: Cursor position after tget:setfocus()

Postby Antonio Linares » Sun Feb 01, 2015 7:54 am

Frances,

Try with:

oGet:bGotFocus := {|| oGet:Setpos( 9 ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cursor position after tget:setfocus()

Postby fraxzi » Mon Feb 02, 2015 12:26 am

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..
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Cursor position after tget:setfocus()

Postby fraxzi » Mon Feb 02, 2015 12:27 am

Hi Ruben,

oGet:Refresh() invokes oGet:GoHome() which always position the cursor to 1.
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Cursor position after tget:setfocus()

Postby Enrico Maria Giordano » Mon Feb 02, 2015 9:38 am

Frances,

this is a working sample:

Code: Select all  Expand view  RUN
#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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Cursor position after tget:setfocus()

Postby fraxzi » Mon Feb 02, 2015 11:59 pm

Hi Enrico,

This is what it needs to be done. the get in oBar fails..

Code: Select all  Expand view  RUN

#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
 
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Cursor position after tget:setfocus()

Postby Enrico Maria Giordano » Tue Feb 03, 2015 9:05 am

Frances,

Code: Select all  Expand view  RUN
oGet:bGotFocus = { || SysRefresh(), oGet:SetPos( Len( RTrim( cVar ) ) + 1 ) }  //now works!


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Cursor position after tget:setfocus()

Postby fraxzi » Wed Feb 04, 2015 3:33 am

Enrico,

OMG... I never thought of Sysrefresh() on this situation. I thought it was a bug somewhere.. :D :D

Thanks man!
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines


Return to FiveWin for Harbour/xHarbour

Who is online

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