Turn off dark mode?
Turn off dark mode?
possible to turn off dark mode support of gadgets to have the full control over the color?
Re: Turn off dark mode?
I can't find where I posted it before. So here it is again.
Code: Select all
;-TOP
Procedure GetCocoaColor(NSColorName.s)
Protected.CGFloat r, g, b, a
Protected NSApp, NSColor, NSColorSpace
; There is no controlAccentColor on macOS < 10.14
If NSColorName = "controlAccentColor" And OSVersion() < #PB_OS_MacOSX_10_14
ProcedureReturn $D5ABAD
EndIf
; There are no system colors on macOS < 10.10
If Left(NSColorName, 6) = "system" And OSVersion() < #PB_OS_MacOSX_10_10
NSColorName = LCase(Mid(NSColorName, 7, 1)) + Mid(NSColorName, 8)
EndIf
NSColorSpace = CocoaMessage(0, 0, "NSColorSpace deviceRGBColorSpace")
NSColor = CocoaMessage(0, CocoaMessage(0, 0, "NSColor " + NSColorName), "colorUsingColorSpace:", NSColorSpace)
If NSColor
CocoaMessage(@r, NSColor, "redComponent")
CocoaMessage(@g, NSColor, "greenComponent")
CocoaMessage(@b, NSColor, "blueComponent")
CocoaMessage(@a, NSColor, "alphaComponent")
ProcedureReturn RGBA(r * 255.0, g * 255.0, b * 255.0, a * 255.0)
EndIf
EndProcedure
Enumeration Windows
#Main
EndEnumeration
Enumeration Gadgets
#MainPanel
#MainButtonDarkMode
#MainSplitter
EndEnumeration
Enumeration Status
#MainStatusBar
EndEnumeration
Procedure SetDarkMode(State)
Protected NSApp, NSAppearance
NSApp = CocoaMessage(0, 0, "NSApplication sharedApplication")
If Not State
NSAppearance = CocoaMessage(0, 0, "NSAppearance appearanceNamed:$", @"NSAppearanceNameAqua")
CocoaMessage(0, NSApp, "setAppearance:", NSAppearance)
CocoaMessage(0, 0, "NSAppearance setCurrentAppearance:", NSAppearance)
Else
CocoaMessage(0, NSApp, "setAppearance:", #nil)
CocoaMessage(0, 0, "NSAppearance setCurrentAppearance:", #nil)
EndIf
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
StatusBarText(#MainStatusBar, 0, "Version v1.01")
EndProcedure
Procedure Main()
Protected toggle
#MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 400, 300, "Window" , #MainStyle)
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
StatusBarText(#MainStatusBar, 0, " Version v1.01")
PanelGadget(#MainPanel, 10, 10, 380, 200)
AddGadgetItem(#MainPanel, -1, "Panel 1")
AddGadgetItem(#MainPanel, -1, "Panel 2")
CloseGadgetList()
ButtonGadget(#MainButtonDarkMode, 10, 220, 240, 25, "Toggle Appearance")
SplitterGadget(#MainSplitter, 0, 0, 400, 300 - StatusBarHeight(#MainStatusBar), #MainPanel, #MainButtonDarkMode)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case #MainButtonDarkMode
SetDarkMode(toggle)
toggle = Bool(Not toggle)
Debug Hex(GetCocoaColor("windowBackgroundColor"), #PB_Long)
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive