PureBasic Forum
https://www.purebasic.fr/english/

OSX Appearance problem
https://www.purebasic.fr/english/viewtopic.php?f=19&t=72289
Page 1 of 1

Author:  Wolfram [ Thu Feb 14, 2019 5:50 pm ]
Post subject:  OSX Appearance problem

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=DL1ZzSuU2cA&feature=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:
;@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

Author:  Wolfram [ Sun Feb 17, 2019 8:59 pm ]
Post subject:  Re: OSX Appearance problem

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

Code:

;//  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

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/