Page 1 of 1

Problem maintaining position of text in a field

Posted: Wed May 17, 2017 3:24 am
by rbytes
I am working on a project in which I want to select HTML tags from a list and insert them into text in a multi-line field. Once all of the desired tags are inserted, the text is then displayed in a browser window.

I have the code completed to achieve this routine. I position the cursor in the text field at the point I want to insert the tag, and click the list item of the desired tag. I then build a temp string consisting of the LEFT$ of the field text up to the insert point, the tag extracted from the list string array, and the RIGHT$ text of the field from the insert point to the end.

The final step is to insert this new string back into the field. When I do that, the text scrolls to the very bottom, and the edited area can not be seen. I have to manually scroll the field text up to see the edit.

Is there any way to position a specific portion of text in the visible area of a field? I thought I could use the command FIELD "edit" SELECT n, n being the location where the tag was inserted. This command does locate the cursor at that point, but it isn't visible until I scroll the field text up by hand. Anyone have a method for either preventing text from scrolling to the bottom when i use the command FIELD "edit" TEXT tagarray$(23), or instantly scrolling the view back up to the cursor location?

Re: Problem maintaining position of text in a field

Posted: Mon May 22, 2017 6:41 am
by GeorgeMcGinn
Without seeing the code and the HTML that you are trying to create, I am having a hard time following what it is you're doing and what or why it isn't working.

From what I understand, it sounds like in HTML you are either or you may need to create a field called <textarea> which allows multi-line text. You can define the number of columns and the number of rows.

Here's a link to some info about <textarea>: https://developer.mozilla.org/en-US/doc ... t/textarea

If you want to email me the code (in case it is not ready to share with everyone), I can have a better understanding of how you are creating your HTML Page using FIELDS.

George.

Re: Problem maintaining position of text in a field

Posted: Mon May 22, 2017 2:09 pm
by rbytes
Thanks, George. I am familiar with textarea in HTML, but that won't solve my problem. It Is not a browser issue, since it occurs only in a multi-line field. From what I see in the documentation, if my text is too large to fit in an ML field, there is no way to control which portion of the text will be visible.

Re: Problem maintaining position of text in a field

Posted: Tue May 23, 2017 8:31 am
by GeorgeMcGinn
Actually, I have a workaround to that as I needed to do something similar.

With the app I put an editor in, I do the following which might help you out.

I put all the text in an array, and then when I display it in a ML TEXT I use pointers to determine which line to start.

Say my ML TEXT box only displays 20 lines, and I want it to display starting at 21, I start set my array index to 21 as the first line written to the TEXT FIELD.

I also use NEXT and PREV buttons and when I click the next button, it adds 20 to the current array pointer and then I recreate the ML TEXT FIELD by concatenation my string with the next 20 occurrences of the array.

George.

rbytes wrote:
Mon May 22, 2017 2:09 pm
Thanks, George. I am familiar with textarea in HTML, but that won't solve my problem. It Is not a browser issue, since it occurs only in a multi-line field. From what I see in the documentation, if my text is too large to fit in an ML field, there is no way to control which portion of the text will be visible.

Re: Problem maintaining position of text in a field

Posted: Tue May 23, 2017 2:15 pm
by rbytes
That's a good idea, and I will use it in my next Prompter update.

Thanks, George.