Help with selecting text in a field

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
petero
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 59
Joined: Sat Jan 20, 2007 4:09 am

Help with selecting text in a field

Post by petero » Tue May 15, 2012 12:53 am

In a normal list field, you can select a line of text and identify the line selected.

I wish to do the same thing under slightly different circumstances.

The field will be on an iPhone. The field width is not wide enough to display what is contained in a line, so I turned off list behavior and dontwrap.

Now, however, I would like to be able to click (touch) that first entry (which because it wrapped around, may cover two to three lines) and have the result of that touch do something.

I have placed a blank line as a separator after each entry that completes the text that is in "one line" but wraps around.

For example, the data in the field might look like this: (the data was entered on one line, not several, when displayed with dontwrap, it wraps.)

This is the first line of
information that I would like
to select.

This is the second line of inform-
ation that I would like to select


Any ideas? (It seems that with list behavior on, i cannot turn off dontwrap.)

Thanks in advance for your suggestions. They are really appreciated.

Peter

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Help with selecting text in a field

Post by shaosean » Tue May 15, 2012 2:48 am

Best bet would to be look at using the DataGrid

petero
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 59
Joined: Sat Jan 20, 2007 4:09 am

Re: Help with selecting text in a field

Post by petero » Tue May 15, 2012 6:44 pm

If I use a data grid, is it possible to have a one column grid?

Can the data in that one column wrap around in the cell?

Is the cell than selectable?

Thank you.

Peter

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Help with selecting text in a field

Post by Klaus » Tue May 15, 2012 8:14 pm

Hi Peter,

why not just try it yourself?
What could happen besides the fact that your computer will explode? :D

This page might help a bit:
http://lessons.runrev.com/m/datagrid
And of course ask here, if you get stuck!


Best

Klaus

petero
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 59
Joined: Sat Jan 20, 2007 4:09 am

Re: Help with selecting text in a field

Post by petero » Wed May 16, 2012 2:37 am

I did try it (before your suggestion) but could not get the contents of a data grid cell to wrap around.

I am trying to think of some creative coding that would let me select the wrapped text in my one column scrolling list field.

Thanks for the suggestion anyway.

peter

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Help with selecting text in a field

Post by shaosean » Wed May 16, 2012 9:18 am

This is the lesson you need to look at..
http://lessons.runrev.com/s/lessons/m/d ... ne-heights

This is the code you need to add

Code: Select all

    put item 2 of theFieldRect \
           + the formattedHeight of field "Label" of me \
           - the bottomMargin of field "Label" of me \
           into item 4 of theFieldRect
    set the rect of field "Label" of me to theFieldRect
    put item 4 of theFieldRect into item 4 of pControlRect

Post Reply

Return to “Talking LiveCode”