It is currently Mon Jun 25, 2018 6:26 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: TouchBar use?
PostPosted: Tue May 08, 2018 3:57 pm 
Offline
User
User

Joined: Fri Jun 04, 2010 9:29 pm
Posts: 38
Location: Sunny Spain
I must be missing something really simple here but ...
How do I code to put application buttons on the TouchBar of my MacBook Pro (October 2017) :?
I can't see anything relevant in the docs or on-line.
Example code would be very welcome as would a link to documentation (if this actually exists).

Dave


Top
 Profile  
Reply with quote  
 Post subject: Re: TouchBar use?
PostPosted: Tue May 08, 2018 7:40 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1259
Location: Germany
At the moment the touch bar in the version PB v5.62 is deactivated because of massive problems with MacOS 10.9 and Xcode 8.x.
PrinterRequester and WebGadget can lead to crashes.
I tested it with MacOS 10.10.x and Xcode 9.x.
It seems to work correctly again with the current version of Xcode. But I can't guarantee it.

You can reactivate the touchbar for PB-APP with a workaround.

But I don't know how you can add your own functions to the touchbar via cocoa.

Translated with www.DeepL.com/Translator

Code:
;-TOP

; Touchbar workaround by mk-soft
; Version v1.03
; Date 08/15/2017

Procedure IsTouchbar()
  Protected standardUserDefaults, r1
  standardUserDefaults = CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults")
  r1 = CocoaMessage(0, standardUserDefaults, "integerForKey:$", @"NSFunctionBarAPIEnabled")
  ProcedureReturn r1
EndProcedure

Procedure DisableTouchbar()
  Protected standardUserDefaults
  If IsTouchbar()
    standardUserDefaults = CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults")
    CocoaMessage(0, standardUserDefaults, "setBool:", #NO, "forKey:$", @"NSFunctionBarAPIEnabled")
    RunProgram(ProgramFilename(), ProgramParameter(), GetCurrentDirectory())
    End
  EndIf
EndProcedure

Procedure EnableTouchbar()
  Protected standardUserDefaults
  If IsTouchbar() = 0
    standardUserDefaults = CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults")
    CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"NSFunctionBarAPIEnabled")
    RunProgram(ProgramFilename(), ProgramParameter(), GetCurrentDirectory())
    End
  EndIf
EndProcedure

; ***************************************************************************************

CompilerIf #PB_Compiler_IsMainFile
 
  Debug IsTouchbar()
  EnableTouchbar()
  ;DisableTouchbar()
 
  If OpenWindow(0, 0, 0, 600, 300, "WebGadget: "+Str(IsTouchbar()), #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
       CreateImage(0,16,16)
    StartDrawing(ImageOutput(0))
      Box(0,0,16,16,RGB(255,255,255))
      Box(4,4,8,8,RGB(255,0,0))
    StopDrawing()
    CreateImage(1,16,16)
    StartDrawing(ImageOutput(1))
      Box(0,0,16,16,RGB(255,0,0))
      Box(4,4,8,8,RGB(255,255,255))
    StopDrawing()
    If CreateToolBar(0, WindowID(0), #PB_ToolBar_Large)
      ToolBarImageButton(0,ImageID(0))
      ToolBarImageButton(1,ImageID(1))
    EndIf
   
    ;Delay(100)
    ; this website doesn't crash the app
    ;WebGadget(0, 10, 10, 580, 280, "http://www.apple.com")
    ; this website crashes the app
    WebGadget(0, 10, 10, 580, 280, "http://google.com")
   
    Repeat
      ; crash with "http://google.com"
    Until WaitWindowEvent() = #PB_Event_CloseWindow  ; <- Invalid memory access
  EndIf
CompilerEndIf

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


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