Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Light and Dark mode detect in html5 exports — Gideros Forum

Light and Dark mode detect in html5 exports

SinisterSoftSinisterSoft Maintainer
edited July 2021 in Code snippets
In your html5 exports use this to detect if you are in light or dark mode - the change your app or game colours to suit...
-- device={application:getDeviceInfo()}
-- device[1]=="Web"
-- only do the next line if html5 export
if JS.eval("window.matchMedia('(prefers-color-scheme:dark)').matches")=="true" then sysDark=1 else sysDark=0 end
You will end up with sysDark being -1 for 'don't know', 0 for 'light' and 1 for 'dark'...

If we can figure it out for Android, iOS, Windows, etc then it could eventually be an application api call instead?
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
+1 -1 (+3 / -0 )Share on Facebook
Sign In or Register to comment.