How to implement an interface: Love the LR :D

So, after seeing the Application.AppearanceChanged event, I thought it would be a good occasion to implement an interface in windows, to update each with different colors when dark mode. So I proceeded to the Good Old Language Reference.

After reading the relevant pages, I have to admit it does not give any idea about what to do :confused:

From Xojo Documentation

Language Keyword

An Interface is used to specify what an object does without specifying how it does it.

You will not use the Interface keyword directly in your code. To add an Interface to your project, use the Insert button or menu. To assign an Interface to a class, use the Interfaces button on the Inspector for the class.

See Also
Class, Implements keyword[/quote]

From Xojo Documentation

Language Keyword

A Class can Implement an Interface.

You will not use the Implements keyword directly in your code. To have a class Implement an Interface, select the Interface using the Interfaces button in the Inspector.

See Also
Class, Interface keywords[/quote]

Fortunately, I found the ActionSourceInterfaceExample. Hopefully, that will shed some light on that mystery feature :smiley:

1 Like

Update: Perhaps I am stupid (probably), because I cannot make heads and tails of the example project.

My idea was probably not that good :frowning:

I will have instead to set a flag in Application.AppearanceChanged , and do what is needed in the window Paint event, then.

If you use GraffitiSuite, I’ve added the code to capture Dark/Light mode system messages for both Windows and macOS in GraffitiColors and use a delegate to notify any object that subscribes.

its more or less a method definition to make classes consistent.
add this interface to your window and you could iterate through all windows in the AppearanceChanged event
and call a method to update the Appearance.

xojo came with a example design patterns / observer

yes the docu is somehow surficial …

If it helps to see an example of how interfaces can be used and implemented, then there is still my lecture available, from the MBS Xojo Conf in Koblenz:

How to use interfaces with databases:

Sample code (old api):

Did you see the interface topic in the User Guide?

FYI, if you create a custom window subclass, you can detect when the appearance has changed by checking IsDarkMode in the window’s Paint event and then raise your own AppearanceChanged event.