OSX Appearance problem

Mac OSX specific forum
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

OSX Appearance problem

Post by Wolfram »

I'm trying to make a custom appearance App with PB, but but it does't work.
I tested in Xcode and it works.

Example:
https://www.youtube.com/watch?v=DL1ZzSu ... e=youtu.be

Link for custom appearance file. Put this into Contents/Resources
http://www.dipole-media.de/Test4.car

Hier the Xcode project. The function is in the ViewController file.
http://www.dipole-media.de/Theme%20Test%20%20C.zip


If the code works you will get a purple button if you click it.

Code: Select all

;@R  Test4.car

Global Window_0, Button_0

;custom appearance
myAppearance = CocoaMessage(0, 0, "NSAppearance alloc") 
appearanceNamed =CocoaMessage(0, myAppearance, "initWithAppearanceNamed:$", @"Test4", "bundle:",  #nil)

;This works
; appearanceNamed  = CocoaMessage(0, 0, "NSAppearance appearanceNamed:$",  @"NSAppearanceNameVibrantDark") ;NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight



Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
	Case #PB_Menu_Quit
          ProcedureReturn #False
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case Button_0
          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure


Window_0 = OpenWindow(#PB_Any, x, y, 450, 160, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Button_0 = ButtonGadget(#PB_Any, 160, 50, 130, 25, "OK")

CocoaMessage(0, WindowID(Window_0), "setAppearance:", appearanceNamed) ;<- this works not with the custom appearance

Repeat
  event = WaitWindowEvent()
Until Window_0_Events(event) = #False
macOS Catalina 10.15.7
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

Re: OSX Appearance problem

Post by Wolfram »

So I found the problem, it was a missing item in the info.pilst file.

Code: Select all


;//  I use the plistTool.app to write my custom info.plist file. http://www.purebasic.fr/english/viewtopic.php?f=27&t=53905
;@@ DisableDebugWindow

;;//This is needed in the info.plist file. You can change it to what you want.
;@@ CFBundleIdentifier = com.MeMyselfAndI.myThemedApp

;;//This copy the Test4.car into the /Recources folder of your App
;@R  Test4.car

Global Window_0, Button_0

myAppearance = CocoaMessage(0, 0, "NSAppearance alloc") 
appearanceNamed =CocoaMessage(0, myAppearance, "initWithAppearanceNamed:$", @"Test4", "bundle:",  #nil)


Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
   Case #PB_Menu_Quit
          ProcedureReturn #False
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case Button_0
          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure


Window_0 = OpenWindow(#PB_Any, x, y, 450, 160, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Button_0 = ButtonGadget(#PB_Any, 160, 50, 130, 25, "OK")

contentView =  CocoaMessage(0, WindowID(Window_0), "contentView")
CocoaMessage(0, contentView, "setAppearance:", appearanceNamed) 


Repeat
  event = WaitWindowEvent()
Until Window_0_Events(event) = #False
Example gray:
Image
macOS Catalina 10.15.7
Post Reply