FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Which line textbox.selectedText() is on

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Oct 28, 2010 12:26 am    Post subject: Which line textbox.selectedText() is on Reply with quote

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:
Quote:

j@j.tv 23
p@p.tv 14
s@s.tv 10


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
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Sun Oct 31, 2010 8:24 pm    Post subject: Re: Which line textbox.selectedText() is on Reply with quote

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
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Wed Dec 01, 2010 10:22 pm    Post subject: Reply with quote

thanks, Chris.

jose
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group