# Visual caret bug after re-log in Windows

**URL:** <https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236>\
**Category:** AlterNET Studio Support\
**Tags:** wpf, editor\
**Created:** [July 16, 2021, 7:54am UTC](https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236 "2021-07-16T07:54:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergio.aguilar](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/s/606060/32.png) [@sergio.aguilar](https://forum.alternetsoft.com/u/sergio.aguilar)\
**Post date:** [July 16, 2021, 7:54am UTC](https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236/1 "2021-07-16T07:54:04Z")

</div>

Hello,  
we noticed a visual bug with with the caret when we work on remote desktop, if we close the session with an editor opened and then we start the remote desktop again, we notice a little change at the font size or font family of the editor, but the worst thing is that the caret is wrong visualy placed. Once it happens the only solution is to close the application and start it again.

 ![alternet bug](https://forum.alternetsoft.com/uploads/default/original/1X/6308a473ac8b58adf4bcac162fd31dac088a6745.png)

We could also reproduce it without RDP changing Windows user and returning to the initial Windows user.

We noticed this bug some versions before(I think v4, but maybe is happening since we started using the editor…).

I’ve prepared a simple sample project using v7.1 where you can reproduce the bug. Also here is a video where you can see exactly what I am talking about.

Sample project: [https://we.tl/t-zms7elwqgZ](https://we.tl/t-zms7elwqgZ)  
Video: [2021-07-16\_09-16-33](https://www.screencast.com/t/gwzYic1LLG)

Regards,  
Sergio.

---

<div class="post-metadata">

**Author:** ![dmitry.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/dmitry.medvedev/32/27_2.png) [@dmitry.medvedev](https://forum.alternetsoft.com/u/dmitry.medvedev)\
**Post date:** [July 20, 2021, 2:28am UTC](https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236/2 "2021-07-20T02:28:36Z")

</div>

Hi Sergio,

Thank you for reporting this issue, we will try to reproduce it, and will get back to you as soon as we find out what’s happening.

Regards,  
Dmitry

---

<div class="post-metadata">

**Author:** ![dmitry.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/dmitry.medvedev/32/27_2.png) [@dmitry.medvedev](https://forum.alternetsoft.com/u/dmitry.medvedev)\
**Post date:** [July 22, 2021, 1:18am UTC](https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236/3 "2021-07-22T01:18:42Z")

</div>

Hi Sergio,

It looks like in this scenario default font is set upon RDP session is reconnected, causing these visual effects. We have fixed it internally, for now you can use the following workaround by deriving your own class from TextEditor and using it in your application,

```
public class Edit : TextEditor
{
    public Edit()
    {
        FontFamilyProperty.AddOwner(typeof(Edit), new FrameworkPropertyMetadata { Inherits = false });
    }
}

```

Let me know if it helps,  
Dmitry

---

<div class="post-metadata">

**Author:** ![sergio.aguilar](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/s/606060/32.png) [@sergio.aguilar](https://forum.alternetsoft.com/u/sergio.aguilar)\
**Post date:** [July 22, 2021, 12:29pm UTC](https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236/4 "2021-07-22T12:29:03Z")

</div>

Hi Dmitry,  
I tested your solution on the project I created for this purpose and your solution seems to work fine, we will do this change in our main solution and will type you with the result.  
On the other hand, about the workaround, won’t you do this kind of things in the static type initializer rather than in the constructor? I tried to put this code in the type initializer, but the error apears since begining without the need of reconnect the RDP session. Will it be any problems if we have more than one editor in the same window?

Thanks,  
Sergio.

---

<div class="post-metadata">

**Author:** ![sergio.aguilar](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/s/606060/32.png) [@sergio.aguilar](https://forum.alternetsoft.com/u/sergio.aguilar)\
**Post date:** [July 22, 2021, 6:25pm UTC](https://forum.alternetsoft.com/t/visual-caret-bug-after-re-log-in-windows/236/5 "2021-07-22T18:25:29Z")

</div>

Well, as I suppossed, the workaround give us a “System.ArgumentException: ‘FontFamily’ was already registered by ‘Editor’”.
