factor/basis/cocoa/touchbar/touchbar.factor

24 lines
989 B
Factor
Raw Normal View History

2017-05-30 13:09:02 -04:00
! Copyright (C) 2017 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types cocoa cocoa.classes cocoa.messages
cocoa.runtime combinators core-foundation.strings kernel locals
;
2017-05-30 13:09:02 -04:00
IN: cocoa.touchbar
: make-touchbar ( seq self -- touchbar )
2017-05-30 13:09:02 -04:00
[ NSTouchBar -> alloc -> init dup ] dip -> setDelegate: {
[ swap <CFStringArray> { void { id SEL id } } ?-> setDefaultItemIdentifiers: ]
[ swap <CFStringArray> { void { id SEL id } } ?-> setCustomizationAllowedItemIdentifiers: ]
2017-05-30 13:09:02 -04:00
[ nip ]
} 2cleave ;
:: make-NSTouchBar-button ( self identifier label-string action-string -- button )
NSCustomTouchBarItem -> alloc
identifier <CFString> { id { id SEL id } } ?-> initWithIdentifier: :> item
2017-05-30 13:09:02 -04:00
NSButton
label-string <CFString>
self
action-string lookup-selector { id { id SEL id id SEL } } ?-> buttonWithTitle:target:action: :> button
2017-05-30 13:09:02 -04:00
item button -> setView:
2017-06-01 14:46:32 -04:00
item ;