# Pixel-perfect scroll position in textarea?

**URL:** <https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838>\
**Category:** Getting Started\
**Created:** [March 21, 2020, 4:24pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838 "2020-03-21T16:24:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farai\_Aschwanden](https://forum.xojo.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@Farai\_Aschwanden](https://forum.xojo.com/u/Farai_Aschwanden)\
**Post date:** [March 21, 2020, 4:24pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/1 "2020-03-21T16:24:06Z")

</div>

Hello

I have a textarea that is a code window where the user can enter code. On the left side of this textarea there is another textarea showing the line numbers. This is all working well. If not all entered code can be seen the user can of course scroll the textarea. I then have to synchronously scroll the other textarea with the line numbers.  
The problem: textarea.VerticalScrollPosition returns the most top visible line number but not the pixel-perfect position. Setting this line number to the other textarea (showing current line number view) then there is a slight shift between both textareas. Well if I then also set the VerticalScrollPosition of the codearea I get them synced but then I have some flickering effects on scrolling the codearea.

Is there a solution where I can get them synced so they are always being at the precise same pixel-perfect vertical position? I also would be happy to be able to set the textarea (code) scrolling step to “line” but I couldn’t find a property for this.

Addon:  
Just saw that textarea.HorizontalScrollPosition is based on pixels while textarea.VerticalScrollPosition is based on lines! This is really weird.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [March 21, 2020, 4:39pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/2 "2020-03-21T16:39:07Z")

</div>

Have a look at [https://github.com/tempelmann/custom-editfield](https://github.com/tempelmann/custom-editfield) . That should do what you want out of the box.

---

<div class="post-metadata">

**Author:** ![Farai\_Aschwanden](https://forum.xojo.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@Farai\_Aschwanden](https://forum.xojo.com/u/Farai_Aschwanden)\
**Post date:** [March 21, 2020, 5:02pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/3 "2020-03-21T17:02:08Z")

</div>

Thank you this looks promising but I have no clue how to “install” this. Beside of tons of files there is an installation chapter not telling me what and how I have to download files (and install where). F.e. he is talking about a “CustomEditField folder” which I don’t have in Xojo. Furthermore I miss a proper manual (inside) and the code looks pretty old, not sure if it is working with latest Xojo releases on Mac, Win, Linux).

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [March 21, 2020, 7:36pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/4 "2020-03-21T19:36:38Z")

</div>

> [@479989:@Farai Aschwanden](#):
>
> not sure if it is working with latest Xojo releases on Mac, Win, Linux).

It does… while CEF was written many years ago. Tomas has taken over and updated it…

---

<div class="post-metadata">

**Author:** ![Farai\_Aschwanden](https://forum.xojo.com/letter_avatar_proxy/v4/letter/f/e79b87/32.png) [@Farai\_Aschwanden](https://forum.xojo.com/u/Farai_Aschwanden)\
**Post date:** [March 21, 2020, 8:46pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/5 "2020-03-21T20:46:57Z")

</div>

Thanks for the additional info. I have to figure out how to “implement” it, I’m not into GIT.

---

<div class="post-metadata">

**Author:** ![brian\_franco](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_franco/32/156_2.png) [@brian\_franco](https://forum.xojo.com/u/brian_franco)\
**Post date:** [March 21, 2020, 8:53pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/6 "2020-03-21T20:53:51Z")

</div>

> [@480015:@Farai Aschwanden](#):
>
> Thanks for the additional info. I have to figure out how to “implement” it, I’m not into GIT.

It can be confusing but find the “clone/download” button and then view the read me in the download

---

<div class="post-metadata">

**Author:** ![PaulS](https://forum.xojo.com/user_avatar/forum.xojo.com/pauls/32/199_2.png) [@PaulS](https://forum.xojo.com/u/PaulS)\
**Post date:** [March 21, 2020, 8:54pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/7 "2020-03-21T20:54:15Z")

</div>

Just click the link given by Beatrix and press the green ‘Clone or download’ button.  
Select ‘Download ZIP’ and when it’s downloaded you can use CEF.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [March 22, 2020, 4:57am UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/8 "2020-03-22T04:57:01Z")

</div>

I don’t know about Linux and Windows. But I have the code working fine on Catalina with Xojo 2019r3. Download the zip file. Run the project. You probably need to copy most of the project items into your project.

---

<div class="post-metadata">

**Author:** ![Tanner\_Lee1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@Tanner\_Lee1](https://forum.xojo.com/u/Tanner_Lee1)\
**Post date:** [March 23, 2020, 8:45pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/9 "2020-03-23T20:45:22Z")

</div>

> [@480040:@Beatrix Willius](#):
>
> I don’t know about Linux and Windows. But I have the code working fine on Catalina with Xojo 2019r3. Download the zip file. Run the project. You probably need to copy most of the project items into your project.

FWIW, I get `CGImage` errors running in 19R3,1. I found just commenting out the offending routines in DragImage allows it to work (esp. since I don’t use Drag+Drop).

> [@480002:@Dave S](#):
>
> It does… while CEF was written many years ago. Tomas has taken over and updated it…

Is there a newer repository beside Tempelmann’s?

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [March 23, 2020, 9:07pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/10 "2020-03-23T21:07:02Z")

</div>

> [@480268:@Tanner Lee](#):
>
> Is there a newer repository beside Tempelmann’s?

[quote=480268:@Tanner Lee]FWIW, I get `CGImage` errors running in 19R3,1. I found just commenting out the offending routines in DragImage allows it to work (esp. since I don’t use Drag+Drop).

Is there a newer repository beside Tempelmann’s?[/quote]  
not officiall that I know of…  
I personally did a lot of changes to it recently, but all for my own purposes, and it including cutting out chunks I didn’t need

The original version did use an image format that included the mask as a side-by-side image, not layers like today

---

<div class="post-metadata">

**Author:** ![Tanner\_Lee1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@Tanner\_Lee1](https://forum.xojo.com/u/Tanner_Lee1)\
**Post date:** [March 24, 2020, 2:57am UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/11 "2020-03-24T02:57:45Z")

</div>

@Dave S Thanks for the info.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [March 24, 2020, 3:02am UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/12 "2020-03-24T03:02:36Z")

</div>

Same here. I have a long IDE Communicator script. With the CEF I now know where to look if I get a compiler error with a line number.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:19pm UTC](https://forum.xojo.com/t/pixel-perfect-scroll-position-in-textarea/52838/13 "2021-04-29T16:19:33Z")

</div>


