Multiget: reading position of the cursor

Post Reply
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Multiget: reading position of the cursor

Post 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.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Multiget: reading position of the cursor

Post by Silvio »

to make what ?
Best Regards, Saludos

Falconi Silvio
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post 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).
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post by gkuhnert »

nobody an idea? Just need to know at which position the cursor is blinking...
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post by gkuhnert »

This problem isn't solved yet...
Maybe someone an idea?
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Multiget: reading position of the cursor

Post by James Bott »

Have you tried oGet:nPos?

James
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post 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.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Multiget: reading position of the cursor

Post by James Bott »

Have you tried bKeydown?

Can you provide a small self contained test program?

Regards,
James
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post 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.
 
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Multiget: reading position of the cursor

Post by Antonio Linares »

Gilbert,

Please try it this way:

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

Antonio Linares
www.fivetechsoft.com
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post by gkuhnert »

Antonio,

many thanks, it is working fine now :D
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Multiget: reading position of the cursor

Post by James Bott »

>it is working fine now

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

James
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Multiget: reading position of the cursor

Post 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.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
Post Reply