[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextEditor highlighter, setting color


On Mon, 22 Dec 2025 at 14:53, Bruce Steers <bsteers4@xxxxxxxxx> wrote:

>
>
> On Sun, 21 Dec 2025 at 16:38, Lee <t.lee.davidson@xxxxxxxxx> wrote:
>
>> On 12/20/25 7:00 PM, Bruce Steers wrote:
>> > I seem to not be able to set TextEditor colors using the
>> Theme[Key].Color property?
>> >
>> > Public Sub ColorChooser1_Change()
>> >
>> >    If cmboStates.Text = "Background" Then
>> >      TextEditor1.Background = ColorChooser1.Value
>> >    Else
>> >      TextEditor1.Theme[cmboStates.Text].Color = ColorChooser1.Value
>> >    Endif
>> >
>> >    TextEditor1.Refresh
>> >
>> > End
>> >
>> > attached is a simple application that "should" allow changing the
>> highlight modes colors.
>> >
>> > it seems "reading" TextEditor1.Theme[cmboStates.Text].Color works as
>> the colors show on the ColorChooser when you select a State
>> > but writing the property does not seem to do anything on the gambas
>> highlighting?
>> >
>> > Or am i missing a trick?
>> >
>> > Respects
>> > BruceS
>> >
>>
>> Weird. The TextHighlighterStyle.Color property is actually getting set.
>> But, TextEditor1.Refresh is not causing the editor's
>> text to be redrawn using the changed color.
>>
>>
>> --
>> Lee
>
>
> Yes, it seems broken.
>
> I found the only visible change (apart from Background) is when setting
> TextEditor1.Theme["Normal"].Color , but it does not change the normal text
> of the document it changes the Line Numbering text color at the left margin.
> Nothing else seems to do anything.
>
> Respects
> BruceS
>

I managed to get it working like this...

Public Sub ColorChooser1_Change()

  If cmboStates.Text = "Background" Then
    TextEditor1.Background = ColorChooser1.Value
  Else
    TextEditor1.Theme[cmboStates.Text].Color = ColorChooser1.Value
    TextEditor1.Theme = TextEditor1.Theme.Copy()
  Endif
  TextEditor1.Refresh

End

Without the "TextEditor1.Theme = TextEditor1.Theme.Copy()" after a
change it does not work.

Respects
BruceS

References:
TextEditor highlighter, setting colorBruce Steers <bsteers4@xxxxxxxxx>
Re: TextEditor highlighter, setting colorLee <t.lee.davidson@xxxxxxxxx>
Re: TextEditor highlighter, setting colorBruce Steers <bsteers4@xxxxxxxxx>