Cursor position in a Get

Cursor position in a Get

Postby Jeff Barnes » Sat Oct 05, 2013 8:30 pm

I have a multiline get. If the user clicks into it, the cursor will be placed where they clicked.
How can I force the cursor to go the the start of the get but only when the get receives the focus.
If the get has the focus, the user should be able to click anywhere they want in the get.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Cursor position in a Get

Postby Armando » Sun Oct 06, 2013 2:00 am

Jeff:

Pls Have a look to Antonio's answer. perhaps it can help you.

viewtopic.php?f=3&t=25979&p=142184&hilit=cursor#p142184

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3224
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Cursor position in a Get

Postby Rick Lipkin » Sun Oct 06, 2013 3:13 pm

Jeff

Consider this code .... the cursor is moved to the first character of the text within the get.

Rick Lipkin
Code: Select all  Expand view

cMEMO  := StrTran( oRs:Fields(cField):Value, Chr( 141 ) + Chr( 10 ), "" )

If empty( cMemo) .or. cMemo = "  "
Else
   cMemo := alltrim( cMemo )
Endif


DO CASE
CASE cMODE = "A"
     cTITLE := cTitle +"      ADD"
CASE cMODE = "E"
     cTITLE := cTitle +"     EDIT"
CASE cMODE = "V"
     cTITLE := cTitle +"     VIEW"
ENDCASE


DEFINE DIALOG oUSERS RESOURCE "MEMO" ;
       TITLE cTITLE              ;


IF cMODE = "E"

   REDEFINE GET oMEMO      VAR cMEMO MEMO ID 130 of oUSERS UPDATE

ELSE     // view

   REDEFINE GET oMEMO      VAR cMEMO ID 130 of oUSERS READONLY

ENDIF


     IF cMODE = 'E'
        oMemo:bGotFocus = { || oMemo:SetSel( 0, 0 ),;
                         oMemo:Goto( oMemo:GetLineCount() ),;
                         __Keyboard( Chr( VK_END ) ) }
     ENDIF

REDEFINE BTNBMP oBtn1 ID 111 of oUSERS   ;     // ok
         RESOURCE "OK", "DOK", "DOK" ;
         PROMPT "  &Ok    " LEFT 2007;
         ACTION (IF(cMODE ="E", _DOIT(cMemo,oRs,cField), ),    ;
                  oUSERS:END()  )

REDEFINE BTNBMP oBtn2 ID 112 of oUSERS   ;    // cancel
         RESOURCE "CANCEL", "DCANCEL", "DCANCEL" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION oUSERS:END()

ACTIVATE DIALOG oUSERS

RETURN( NIL )

 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Cursor position in a Get

Postby Jeff Barnes » Sun Oct 06, 2013 6:43 pm

Thanks Guys.
Got it working with: oGet1:bGotFocus := {|| oGet1:SetPos(0,0) }
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests