TextField problem

Using a TextField and its TextColor property, how do I code it for setting the default color when I hit a PushButton in the Action event?

TextField1.TextColor = &c000000

I want it to be the default color whether in Dark mode or Light mode. i.e. black when in Light mode and white when in Dark mode.

It’s always a good idea to check the documentation, especially the “see also” bit at the end.

http://documentation.xojo.com/api/deprecated/highlightcolor.html Might help (no guarantees)

Also look at https://blog.xojo.com/2018/10/23/join-the-dark-side/ and the links therein, as well as https://forum.xojo.com/50734-cstruecolors-for-full-mojave-dark-mode-color-handling-more

I put this in DefaultButton.Action

TextField1.TextColor = &c000000

When I run the program the TextField1 shows white for Dark mode and black for Light mode (see pics).

I have this in TextField1.Open

// Set properties when the TextField is initialized Me.TextFont = "Courier" Me.TextSize = 63

When I switch to R, G, or B it works and when I hit the Default button it switches to white in Dark mode and black in Light mode.

I was trying this in DefaultButton.Action which isn’t working…

//Set default color of TextField1
Dim result As Boolean

If result = IsDarkMode = True Then //MsgBox("I am in Dark mode!") TextField1.TextColor = &cFFFFFF ' switch to white ElseIf result = IsDarkMode = False Then //MsgBox("I am in Light mode!") TextField1.TextColor = &c000000 ' switch to black End If


You could just use the TextColor global.

TextField1.TextColor = TextColor

That did it, Anthony. Thank you. So close and yet so far. LOL

Happy to help!

Kudos on the commenting but why do you use boolean = boolean = boolean and elseif???

Why do you not simply write

[code]If IsDarkMode Then // I am in Dark mode
TextField1.TextColor = &cFFFFFF ’ switch to white

Else // I am in Light mode
TextField1.TextColor = &c000000 ’ switch to black

End If[/code]

and with the use of the global TextColor you can even dispense of the if…then…else and simply do

TextField1.TextColor = TextColor

I guess I did not understand your problem, but since you are relying on textcolor, then why do you ever need to set it explicitly?
Switching to light/dark mode does the job automatically, does’nt it?
Unless the textfield gets a different textcolor (for instance textfield.1textcolor = color.blue) somewhere else.