Multiget: reading position of the cursor

Multiget: reading position of the cursor

Postby gkuhnert » Mon Feb 21, 2011 9:57 am

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
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: Multiget: reading position of the cursor

Postby Silvio » Mon Feb 21, 2011 11:48 am

to make what ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Multiget: reading position of the cursor

Postby gkuhnert » Mon Feb 21, 2011 12:31 pm

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

Re: Multiget: reading position of the cursor

Postby gkuhnert » Mon Feb 28, 2011 2:54 pm

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

Re: Multiget: reading position of the cursor

Postby gkuhnert » Tue Apr 05, 2011 3:46 pm

This problem isn't solved yet...
Maybe someone an idea?
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

Re: Multiget: reading position of the cursor

Postby James Bott » Tue Apr 05, 2011 5:56 pm

Have you tried oGet:nPos?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Multiget: reading position of the cursor

Postby gkuhnert » Wed Apr 06, 2011 7:38 am

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
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: Multiget: reading position of the cursor

Postby James Bott » Wed Apr 06, 2011 2:50 pm

Have you tried bKeydown?

Can you provide a small self contained test program?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Multiget: reading position of the cursor

Postby gkuhnert » Thu Apr 07, 2011 8:42 am

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  Expand view
#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
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: Multiget: reading position of the cursor

Postby Antonio Linares » Fri Apr 08, 2011 11:37 am

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
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multiget: reading position of the cursor

Postby gkuhnert » Fri Apr 08, 2011 12:38 pm

Antonio,

many thanks, it is working fine now :D
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

Re: Multiget: reading position of the cursor

Postby James Bott » Fri Apr 08, 2011 12:44 pm

>it is working fine now

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

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Multiget: reading position of the cursor

Postby gkuhnert » Fri Apr 08, 2011 2:22 pm

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
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests