Cursor position at top of textArea
-
- New User
- Posts: 17
- Joined: Mon Feb 01, 2016 3:42 pm
- First Name: Mario
- Last Name: Javier
- Company Name: Trimble
- Phone: 440-721-2890
- Address 1: 6350 Quadrangle Dr.
- Address 2: Suite 300
- City: Chapel Hill
- State / Province: North Carolina
- Zip / Postal Code: 27517
- Country: United States
- Contact:
Cursor position at top of textArea
Is there a way to position the cursor at the top of the textArea. I've searched google but could not find any Profound specific textArea widget.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Cursor position at top of textArea
Isn't that where it positions to when you tab to the text area?
Under what circumstances do you want it to behave differently?
Under what circumstances do you want it to behave differently?
-
- New User
- Posts: 17
- Joined: Mon Feb 01, 2016 3:42 pm
- First Name: Mario
- Last Name: Javier
- Company Name: Trimble
- Phone: 440-721-2890
- Address 1: 6350 Quadrangle Dr.
- Address 2: Suite 300
- City: Chapel Hill
- State / Province: North Carolina
- Zip / Postal Code: 27517
- Country: United States
- Contact:
Re: Cursor position at top of textArea
When the textArea contains about 2000 characters. The cursor would position to the bottom, or at the end of the textArea. What we wanted to do is to be consistent with the green screen "subfile" where the first record is positioned at the top along with the cursor.
Last edited by mjavier on Mon Jun 25, 2018 2:15 pm, edited 1 time in total.
- Megan
- Profound Logic Staff Member
- Posts: 90
- Joined: Mon Sep 11, 2017 12:15 pm
- First Name: Megan
- Last Name: Bond
- Company Name: Profound Logic
- Phone: 5623227473
- State / Province: California
- Zip / Postal Code: 92692
- Country: United States
- Contact:
Re: Cursor position at top of textArea
Hello Mario,
It is possible to position the cursor at the top. This would be accomplished with JavaScript added to an event of the widget. For your situation, you may want to use the onfocus or onclick events. Here is some example code:
When this code is added to the onfocus event, it will scroll to the top of the widget and position the cursor at the start when focused in some way other than clicking directly in the widget (so by tab or by clicking non-text areas of the widget). Click the text area of the widget will position the cursor at the click-point.
When this code is added to the onclick event, it will scroll to the top of the widget and position the cursor at the start any time the widget is clicked. This means that the cursor can only be moved with the arrow keys inside the textarea, clicking will always reset it to the start (0) position.
We hope this helps!
Thanks,
It is possible to position the cursor at the top. This would be accomplished with JavaScript added to an event of the widget. For your situation, you may want to use the onfocus or onclick events. Here is some example code:
Code: Select all
input = this; // 'This' refers to the element that had its event triggered.
input.scrollTop = 0; // Scroll to the the top of the widget.
if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(0, 0);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', 0);
range.moveStart('character', 0);
range.select();
}
When this code is added to the onclick event, it will scroll to the top of the widget and position the cursor at the start any time the widget is clicked. This means that the cursor can only be moved with the arrow keys inside the textarea, clicking will always reset it to the start (0) position.
We hope this helps!
Thanks,
-
- New User
- Posts: 17
- Joined: Mon Feb 01, 2016 3:42 pm
- First Name: Mario
- Last Name: Javier
- Company Name: Trimble
- Phone: 440-721-2890
- Address 1: 6350 Quadrangle Dr.
- Address 2: Suite 300
- City: Chapel Hill
- State / Province: North Carolina
- Zip / Postal Code: 27517
- Country: United States
- Contact:
Re: Cursor position at top of textArea
Thank you Megan. This works.
Who is online
Users browsing this forum: No registered users and 4 guests