FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Cursor position after tget:setfocus()
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Cursor position after tget:setfocus()

Posted: Sat Jan 31, 2015 05: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
Posts: 555
Joined: Wed Jul 31, 2013 01:14 PM

Re: Cursor position after tget:setfocus()

Posted: Sat Jan 31, 2015 01: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 2501, Harbour, MVS2022 Community, MySql & MariaDB, Dbf/Cdx VSCode.

Maldonado - Uruguay
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Cursor position after tget:setfocus()

Posted: Sun Feb 01, 2015 07:54 AM

Frances,

Try with:

oGet:bGotFocus := {|| oGet:Setpos( 9 ) }

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Re: Cursor position after tget:setfocus()

Posted: 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
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Re: Cursor position after tget:setfocus()

Posted: 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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Cursor position after tget:setfocus()

Posted: Mon Feb 02, 2015 09:38 AM
Frances,

this is a working sample:

Code (fw): Select all Collapse
#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
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Re: Cursor position after tget:setfocus()

Posted: Mon Feb 02, 2015 11:59 PM
Hi Enrico,

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

Code (fw): Select all Collapse
#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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: Cursor position after tget:setfocus()

Posted: Tue Feb 03, 2015 09:05 AM
Frances,

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


EMG
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Re: Cursor position after tget:setfocus()

Posted: Wed Feb 04, 2015 03: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

Continue the discussion