# Is this a Bug in subclassing?

**URL:** <https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447>\
**Category:** General\
**Created:** [July 21, 2019, 5:17pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447 "2019-07-21T17:17:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Tellez](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/a9a28c/32.png) [@Ivan\_Tellez](https://forum.xojo.com/u/Ivan_Tellez)\
**Post date:** [July 21, 2019, 5:17pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/1 "2019-07-21T17:17:50Z")

</div>

Xojo 2019 r1.1 and Windows

I have some clients complaining about my app not being compliant with a hight contrast setting, and I want it to be, but is not an easy task with the lack of functionality from xojo

For example, for the BevelButton, if I put in the Open event:

```auto
Me.TextColor = TextColor
```

It works, now the text color is the System’s text color (Not just black) and it can work with themes like the hight contrast, so, for an “easier” transition, I make a decided to make a Subclass, aded a new class, set its super to BevelButton and in the open event put the same code.

Drag the new subclas to a window, run the program and Surprise! Didnt work, the text is just Black

---

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [July 21, 2019, 6:41pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/2 "2019-07-21T18:41:14Z")

</div>

platform and xojo version?

What if in the open even you put:  
me.TextColor = &cFB002000

Do you see red text?

---

<div class="post-metadata">

**Author:** ![Ivan\_Tellez](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/a9a28c/32.png) [@Ivan\_Tellez](https://forum.xojo.com/u/Ivan_Tellez)\
**Post date:** [July 21, 2019, 6:55pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/3 "2019-07-21T18:55:21Z")

</div>

[quote=446134:@Karen Atkocius]platform and xojo version?

What if in the open even you put:  
me.TextColor = &cFB002000

Do you see red text?[/quote]

Ups, forgot that part. I did the test with me.TextColor = Color.Red and Yes, it works, also with me.TextColor = &cFB002000, But Me.TextColor = TextColor does not work in the subclased open.

Im using Xojo 2019 r1.1 and Windows

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [July 21, 2019, 7:32pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/4 "2019-07-21T19:32:06Z")

</div>

Probably because youre retrieving the TextColor property of the button. Try

```auto
Me.TextColor = RealBasic.TextColor
```

---

<div class="post-metadata">

**Author:** ![Ivan\_Tellez](https://forum.xojo.com/letter_avatar_proxy/v4/letter/i/a9a28c/32.png) [@Ivan\_Tellez](https://forum.xojo.com/u/Ivan_Tellez)\
**Post date:** [July 21, 2019, 7:42pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/5 "2019-07-21T19:42:36Z")

</div>

[quote=446139:@Anthony Cyphers]Probably because youre retrieving the TextColor property of the button. Try

```auto
Me.TextColor = RealBasic.TextColor
```

Well, that is really odd. TextColor works well alone in all other cases except from the subclass. But RealBasic.TextColor did works also in there.

Thanks

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [July 21, 2019, 7:44pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/6 "2019-07-21T19:44:03Z")

</div>

In a subclass, the scope changes. So when you just use = TextColor, thats equivalent to = Super.TextColor rather than = RealBasic.TextColor.

---

<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:01pm UTC](https://forum.xojo.com/t/is-this-a-bug-in-subclassing/49447/7 "2021-04-29T16:01:11Z")

</div>


