View previous topic :: View next topic |
Author |
Message |
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Thu Oct 28, 2010 12:26 am Post subject: Which line textbox.selectedText() is on |
|
|
Greetings.
Imagine the following scenario...
I have a textbox that opens with a list of emails. Each email is followed with a space " " and then a number. Something like this:
and so on. I have this function:
Code: |
protected void PreviousVendor_doubleclick(Object sender, EventArgs ea)
{
//msgBox(PMAddress.selectedText());
char[][] s = std.string.split(PMAddress.selectedText()," ");
vEmail.text = std.string.strip(s[0]);
EmailForm.close();
}
|
which captures the email address when I double click on the email. The problem is when an email has a - on the email. Say,
jose@jose-some.info
What happens is that selectedText() just grabs jose@jose and ignores "-some.info". I know this is probably something to do with the way a continuous word is defined. In other words, how one defines a white space. - is probably a white space. The question is, how can I always grab the full email? The full email is always followed by a space. Is there a way for me to know which one is the line that I double click on?
thanks,
jose |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Sun Oct 31, 2010 8:24 pm Post subject: Re: Which line textbox.selectedText() is on |
|
|
Here's how I get the line the user clicked in a text box.
Code: | auto pt = myTextBox.pointToClient(Cursor.position);
auto charidx = myTextBox.getCharIndexFromPosition(pt);
auto line0idx = myTextBox.getLineFromCharIndex(charidx); // 0 based.
if(line0idx >= 0)
{
auto lines = myTextBox.lines;
if(line0idx < lines.length)
{
auto userLine = lines[line0idx]; |
|
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Wed Dec 01, 2010 10:22 pm Post subject: |
|
|
thanks, Chris.
jose |
|
Back to top |
|
|
|