I’m going to ask about changing colors

I want to set the font or text color for a Window, button, ComboBox, etc.

And I want to specify the font or color for the entire project at once.

Sounds like you need to define yourself some preferences, figure out how to store them in (say) an SQLite database and make yourself a prefs pane where you set your defaults. Then you apply those as appropriate throughout the app.

This is the first thing I do with an app.

I want to know why SQL is used to change colors and the reason behind it.

Sometimes when people ask questions worded similar to this they are looking for how to make a user-facing setting. Settings do not need to be SQLite. There are more efficient ways to implement settings.

It would be helpful if you could clarify. Are you looking to implement a user-facing setting in your application? Or are you just looking to change all the control text colors in the project with one change?

2 Likes

To follow up on Tim’s post:

If you are looking to implement some standardization for controls that your are adding in the IDE, you could look at subclassing the specific controls.

For example, you could create a subclass of the DesktopBevelButton, then add some code to the Opening Event Handler to set specific properties. That subclassed control is then available in the Control Library, under Project Controls (you may need to scroll pretty far down to find it). As long as all of your DesktopBevelButtons are your subclassed ones, they should behave consistently. If you have already created several DesktopBevelButtons in your project, you can assign their SuperClass to your customized subclass and insure the consistent behaviour/appearance.

No, Themes does not exists in Xojo (except for the IDE itself).

As already set:
add a Preferences window to choose the color(s) and allow to change the color(s)
save the default color(s) to ApplicationData using what you want or a small SQLite data base.
Using SQLite from the start is a good idea considering your – may yhave to add more specific settings to your application.
But not mandatory. Take the approach yo’re familiar with (or try a new one if you have time).

Write a function that extends or passes in a window/desktop window and the iterates through all the controls on the window. Based on control class set font name and colors as you see fit. Pass the font name etc into function or use a global constant in a module.

I do this for “system small” font name which does not seem to exist on windows so I set font size to 10 when I find it.

No need for SQLite etc unless you want users to change / configure at runtime.

If you want themes, pass in an enum for the theme and set color as required.

I’m not using SQL to change colours. I’m using an SQL database to store values corresponding to various settings. I probably have more than 50 separate user settings for my main app, I’m not going to go fiddling about parsing text to extract values from a text file.That is what databases are for. The user doesn’t do anything with SQL, they enter values in fields, and the Prefs panes then validate the values before storing and applying them.

When else is a user going to configure their copy of the app with their account details etc?

What I read from original post was they wanted to set colors etc for entire project. To be built or hardcoded. Change it once rebuild app and new colors are used.

Allowing users to customize colors was not asked for. So seemed a little overboard. That was just my interpretation of their post.

1 Like

So, be prepared for this demand.

With binary files, you avoid both problems.

i made a feature request long ago to have a function called as property value.
this method could get any value at runtime also usefully for translation.

… not found it, i made a new feature request, all of you can vote.
https://tracker.xojo.com/xojoinc/xojo/-/issues/78739