Multiget: reading position of the cursor
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Multiget: reading position of the cursor
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.
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.
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
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)Silvio wrote:to make what ?
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).
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
nobody an idea? Just need to know at which position the cursor is blinking...
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
This problem isn't solved yet...
Maybe someone an idea?
Maybe someone an idea?
- 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
Have you tried oGet:nPos?
James
James
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
yes, but if I use it with bChanged it evaluates the position of the cursor before processing the movement of the cursor.James Bott wrote:Have you tried oGet:nPos?
James
- 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
Have you tried bKeydown?
Can you provide a small self contained test program?
Regards,
James
Can you provide a small self contained test program?
Regards,
James
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
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!
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.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Multiget: reading position of the cursor
Gilbert,
Please try it this way:
oGet:OnKeyDown := { || oGet:cText := omGet:GetCol() }
omGet:OnKeyDown := { || oGet:PostMsg( WM_KEYDOWN ) }
Please try it this way:
oGet:OnKeyDown := { || oGet:cText := omGet:GetCol() }
omGet:OnKeyDown := { || oGet:PostMsg( WM_KEYDOWN ) }
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
Antonio,
many thanks, it is working fine now
many thanks, it is working fine now
- 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
>it is working fine now
Except that it shows 1 when first run, and actually it should show 10.
James
Except that it shows 1 when first run, and actually it should show 10.
James
- gkuhnert
- Posts: 274
- Joined: Fri Apr 04, 2008 1:25 pm
- Location: Aachen - Germany // Kerkrade - Netherlands
- Contact:
Re: Multiget: reading position of the cursor
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.
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.