1 ! Copyright (C) 2017 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.enums alien.syntax cocoa cocoa.classes
4 cocoa.messages combinators core-foundation.strings kernel locals
5 namespaces sequences words ;
8 ! ui.backend.cocoa.views creates buttons for each of these actions
9 ENUM: default-touchbar refresh-all-action auto-use-action ;
11 : enum>CFStringArray ( seq -- alien )
14 swap <CFStringArray> -> initWithArray: ;
16 : make-touchbar ( enum self -- touchbar )
17 [ NSTouchBar -> alloc -> init dup ] dip -> setDelegate: {
18 [ swap enum>CFStringArray -> setDefaultItemIdentifiers: ]
19 [ swap enum>CFStringArray -> setCustomizationAllowedItemIdentifiers: ]
23 :: make-NSTouchBar-button ( self identifier label-string action-string -- button )
24 NSCustomTouchBarItem -> alloc
25 identifier <CFString> -> initWithIdentifier: :> item
27 label-string <CFString>
29 action-string lookup-selector -> buttonWithTitle:target:action: :> button
30 item button -> setView: