It is currently Tue Sep 29, 2020 12:05 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: OSX Appearance problem
PostPosted: Thu Feb 14, 2019 5:50 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 520
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


Top
 Profile  
Reply with quote  
 Post subject: Re: OSX Appearance problem
PostPosted: Sun Feb 17, 2019 8:59 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 520
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye