Page 1 of 1

Multiget: reading position of the cursor

Posted: Mon Feb 21, 2011 9:57 am
by gkuhnert
Hi,

with mGet:OnKeyDown() (using oGet:GetCol()) I can read the position of the cursor before the usage of the key is being handled. Now I need to know the position of the cursor after the key is being used.
To explain: I've got a mget field and want to display the actual position of the cursor. With OnKeydown I get the position where the cursor was before I pressed a key.
Maybe someone has got an idea?

Thanks in advance.

Re: Multiget: reading position of the cursor

Posted: Mon Feb 21, 2011 11:48 am
by Silvio
to make what ?

Re: Multiget: reading position of the cursor

Posted: Mon Feb 21, 2011 12:31 pm
by gkuhnert
Silvio wrote:to make what ?
I need the actual column of the cursor after KeyDown has been processed. So if the cursor blinks at position 3 and I press the right-arrow key, the cursor jumps to position 4, which is the value I need. But with OnKeyDown I get value 3. (I guess, because OnKeyDown is being processed before the actual pressed right-arrow key)

Example: notepad++ has an info at the bottom in which line number and at which column number the cursor is at the moment. That's what I want for my program (only column, don't need the line).

Re: Multiget: reading position of the cursor

Posted: Mon Feb 28, 2011 2:54 pm
by gkuhnert
nobody an idea? Just need to know at which position the cursor is blinking...

Re: Multiget: reading position of the cursor

Posted: Tue Apr 05, 2011 3:46 pm
by gkuhnert
This problem isn't solved yet...
Maybe someone an idea?

Re: Multiget: reading position of the cursor

Posted: Tue Apr 05, 2011 5:56 pm
by James Bott
Have you tried oGet:nPos?

James

Re: Multiget: reading position of the cursor

Posted: Wed Apr 06, 2011 7:38 am
by gkuhnert
James Bott wrote:Have you tried oGet:nPos?

James
yes, but if I use it with bChanged it evaluates the position of the cursor before processing the movement of the cursor.

Re: Multiget: reading position of the cursor

Posted: Wed Apr 06, 2011 2:50 pm
by James Bott
Have you tried bKeydown?

Can you provide a small self contained test program?

Regards,
James

Re: Multiget: reading position of the cursor

Posted: Thu Apr 07, 2011 8:42 am
by gkuhnert
James, bKeyDown won't work, because then the normal bKeyDown won't be processed anymore. So I used OnKeyDown which provides me with the position of the cursor before actually changing it. (Just use the left and right arrow keys and when the cursor jumps into the next line you'll see what my problem is.

Thanks for your help!

Code: Select all

#include "fivewin.ch"

function main()
local oDlg, omGet, oGet
local cGet := 0
local cmGet := "Testing 1"+CRLF+"Testing 2"

    DEFINE DIALOG oDlg FROM 5, 5 TO 30, 44 TITLE "Cursor Position Test"

        @ 1,1 GET oGET VAR cGet OF oDlg SIZE 25,10 //DISABLED
        @ 3,1 GET omGet VAR cmGet OF oDlg SIZE 140,140 MULTILINE

        oGet:Disable()
        //omGet:bKeyDown := {|| oGet:cText := omGet:GetCol()}
        omGet:OnKeyDown := {|| oGet:cText := omGet:GetCol()}

    ACTIVATE DIALOG oDlg

return .t.
 

Re: Multiget: reading position of the cursor

Posted: Fri Apr 08, 2011 11:37 am
by Antonio Linares
Gilbert,

Please try it this way:

oGet:OnKeyDown := { || oGet:cText := omGet:GetCol() }
omGet:OnKeyDown := { || oGet:PostMsg( WM_KEYDOWN ) }

Re: Multiget: reading position of the cursor

Posted: Fri Apr 08, 2011 12:38 pm
by gkuhnert
Antonio,

many thanks, it is working fine now :D

Re: Multiget: reading position of the cursor

Posted: Fri Apr 08, 2011 12:44 pm
by James Bott
>it is working fine now

Except that it shows 1 when first run, and actually it should show 10.

James

Re: Multiget: reading position of the cursor

Posted: Fri Apr 08, 2011 2:22 pm
by gkuhnert
James,

you're right, but because I position the cursor at column 1 when I initialize the multiline get, it's ok for me.

However, another small problem came up: when I use the mouse to reposition the cursor the position isn't updated.