the line number of the top line in a text field

Mike Bonner bonnmike at gmail.com
Sun Jul 1 09:46:59 EDT 2012


Just noticed a small issue. Might want to add a few pixels to the x,y
coords of tFieldLoc for those occaisions when the blank space between lines
is at the top of the field. (in this situation it can return the line
number of the unseen line)

On Sun, Jul 1, 2012 at 7:44 AM, Mike Bonner <bonnmike at gmail.com> wrote:

> I'm not sure this is a good way to do so, but maybe it will work for you.
>
> I created a field with different text sizes/line heights.
>
> In a button is the following script
>
> on mouseUp
>    lock screen
>    put globalloc(the topleft of field 1) into tFieldLoc -- get the
> screenloc position of the topleft of the field
>    put the screenmouseloc into tOldLoc -- save the old mouseloc
>    set the screenmouseloc to tFieldLoc --point to the topleft of the field
>    wait 10 milliseconds with messages -- this is required for the engine
> to do its mouse thang
>    put the mouseline -- Tells you what line the mouse is pointing at
>    set the screenmouseloc to tOldLoc -- back to the old location
>    unlock screen
> end mouseUp
>
> It would probably work with a wait of zero unless there are a ton of
> pending messages (not sure exactly how that part works, does it process all
> pending messages before returning control no matter what wait delay is set?)
>
>
> On Sun, Jul 1, 2012 at 1:51 AM, James Hale <james at thehales.id.au> wrote:
>
>> Is there a way to determine the line number of the top line of a text
>> field?
>>
>> The field's textheight is NOT set as the text present comes from html and
>> different heading levels are present.
>>
>> Context:
>> I am using an rTree object to provide an hierarchical list of these
>> headings and clicking on a node within the tree scrolls the field so that
>> the appropriate line is placed at the top of the field.
>>
>> Issue:
>> I would like to display the current section (heading) name in a small
>> "heading" field above the display field based on the user scrolling through
>> the field.
>> As they scroll past the next heading line I would like the "heading"
>> field to reflect this.
>>
>> However there doesn't seem to be a way of going the other way. Getting
>> the line of the field sitting at the top of the field.
>>
>> Its as if the field contents and its actual display are using two
>> different systems, text chunks versus pixel graphics.
>> Livecode can seemlessly go from specifying the text chunk translating it
>> to the appropriate pixel value of the vscroll, but it can't do the reverse.
>>
>>
>> James
>>
>>
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>



More information about the Use-livecode mailing list