Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: jeff houser
  Where is jeff houser?
 redding
 California - United States
 jeff houser
 Tags
Subject: RE: EditBox
Thread ID: 393805 Message ID: 393809 # Views: 54 # Ratings: 0
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Tuesday, December 24, 2013 5:23:39 AM         
   


> How to Determine cursor's position in an EditBox.
> My Scenario, if the users enters 20 characters and the string is then wrapped into 2-lines, how to detect the number of characters to the left of the cursor's position if the cursor is not at the end of the string. I'm successful in detecting the cursor's position post the keypress of right and left navigational keys. In this situation, I'm just incrementing or decrementing a numeric property. However, my difficulty lies with capturing the cursor's position post the keypress of the up or down navigational keys.
>
> I'm currently using Bindevents for MouseUp and KeyPress to capture the editbox's "SelStart" value.
>
> This is my first posting, so please let me know If additional information is needed.
>
> Jeff

If I correctly understand your request, you can use NODEFAULT in the keypress event, but you have to treat the navigation keys.

PUBLIC oFrm
oFrm=CREATEOBJECT("MyForm")
oFrm.show()

DEFINE CLASS MyForm as Form
	keypreview=.T.
	ADD OBJECT edt as editbox
	ADD OBJECT txt as textbox WITH top=80
	PROCEDURE edt.keypress
		LPARAMETERS nkey,nshift
		IF !INLIST(nkey,9,15) && TAB, SHIFT+TAB, etc.
			NODEFAULT
			DODEFAULT(nkey,nshift)
			MESSAGEBOX(This.selstart)
		ENDIF
	ENDPROC
ENDDEFINE


My respects

ENTIRE THREAD

EditBox Posted by jeff houser @ 12/24/2013 3:08:03 AM
RE: EditBox Posted by Vilhelm-Ion Praisach @ 12/24/2013 5:23:39 AM
RE: EditBox Posted by David Mustakim @ 12/24/2013 5:23:49 AM