Colours
What is the best way to get hold of the current colour theme and colours? I want to use the same colours.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Stuart Beesley ... on 21 Feb, 2022 05:08 PM
MD_REF needs to be set to the moneydance context
currentTheme = MD_REF.getUI().getCurrentTheme()
id = currentTheme.getThemeID()
if currentTheme.isSystemDark() then xxx
examples:
RED:
MD_REF.getUI().getColors().errorMessageForeground
BLUE:
MD_REF.getUI().getColors().defaultTextForeground
Dark Green:
MD_REF.getUI().getColors().budgetHealthyColor
Refer:
com.moneydance.apps.md.view.gui.MDColors
Hope this helps? If not shout, with what else you need?
2 Posted by Mike Bray (Quot... on 23 Feb, 2022 08:24 AM
Thanks Stuart, I have always had problems with getting the context. Once you have it you can navigate the data. How do you get the context?
3 Posted by Mike Bray (Quot... on 23 Feb, 2022 08:48 AM
Found it, the FeatureContext passed is an Main object which contains the ui but this is null until you invoke the extension. Once invoked you can get hold of the UI and then get hold of the colors.
Support Staff 4 Posted by Sean Reilly on 23 Feb, 2022 09:09 AM
There's a singleton for the MDColors class which you're welcome to use:
'colors = com.moneydance.apps.md.view.gui.MDColors.getSingleton()'
The colors object has all of the different colors in use as public members. If the color theme changes then those members are updated with the new values.
Cheers,
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
5 Posted by Mike Bray (Quot... on 23 Feb, 2022 11:22 AM
You can get to the colors by casting the context and ui to the appropriate class.
The code is:
This must be done after the extension is 'invoked'. The ui us null when the extension is intialized.6 Posted by Mike Bray (Quot... on 23 Feb, 2022 11:24 AM
Thanks Sean for the pointer.
Support Staff 7 Posted by Sean Reilly on 23 Feb, 2022 11:26 AM
If you use the MDColors.getSingleton() call you don't need the UI or even the extension context. In general you should access the colors when you are showing the UI, not during extension initialisation. The MDColors object will always be the same object, but the color properties will change as the app is running. So it's a good idea to get the colors at the point where you are creating the UI, not in the extension initialisation.
Cheers,
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
8 Posted by Mike Bray (Quot... on 23 Feb, 2022 11:48 AM
Is there a listener for changing the theme/preferences so I know when the colours have changed?
Sent from Mail for Windows
9 Posted by Stuart Beesley ... on 23 Feb, 2022 12:07 PM
from com.moneydance.apps.md.controller import PreferencesListener
Method preferencesUpdated()
10 Posted by Stuart Beesley ... on 23 Feb, 2022 12:38 PM
Within .preferencesUpdated() you can then do this...
System closed this discussion on 25 May, 2022 12:40 PM.