
NSTouchBar API Reference - tempw
https://developer.apple.com/reference/appkit/nstouchbar?language=objc
======
leonardoe
I can't wait to write a nyan cat app for the TouchBar.

Hopefully the next XCode build will include a TouchBar simulator so there's no
need for me to get a new MBP in order to work on this.

~~~
beefsack
I'm having a little trouble figuring out if this comment was sarcastic or not.
Regardless, I think it illustrates pretty clearly why a lot of us are really
uninterested in the TouchBar.

~~~
epistasis
I'm not sure why a particular entertainment application would explain
disinterest in the feature.

On rough days, I turn on `nyan-mode` [1] in Emacs. I don't think the existence
of nyan-mode should turn anybody off from Emacs.

[1]
[https://www.emacswiki.org/emacs/NyanMode](https://www.emacswiki.org/emacs/NyanMode)

~~~
TeMPOraL
Nyan Mode creator here. If someone borrows me a new Mac for development and
testing, I'll happily make it work on the touch bar :).

------
evanosaurus
>Do not show alerts in the Touch Bar, and do not use the Touch Bar for
widgets.

It's interesting, then, that they explicitly showed the Touch Bar being used
for alerts in the design video (when the user received a FaceTime call).

~~~
sjwright
An incoming call isn't an alert. It's a highly time sensitive notification.

An alert is something that blocks further input until it is dismissed.
Something along the lines of "Are you sure you want to disable encryption?" or
"This item can not be deleted because it is locked."

------
jasonjei
When the OS hasn't initialized Touch Bar, what happens to the Touch Bar? Is
there a default Touch Bar loaded in firmware in cases of Linux or Windows in
Boot Camp?

~~~
bowmessage
I hope I can display the world's narrowest game of pong

~~~
eric_h
That's actually an amusing idea if you rotate it 90 degrees and use the main
display for most of the "table"

~~~
WWKong
How about Bricks game for not having to rotate?

------
CalChris
Well, the Slashdot article gets it right:

    
    
      Apple's New MacBook Pro Requires a $25 Dongle To Charge Your iOS Device
    

I like the TouchBar. I really like the Security Enclave. I'm good with losing
most of the ports. But they shoulda kept a standard USB port.

So this will push my upgrade back not forward.

[https://hardware.slashdot.org/story/16/10/27/2226215/apples-...](https://hardware.slashdot.org/story/16/10/27/2226215/apples-
new-macbook-pro-requires-a-25-dongle-to-charge-your-ios-device)

~~~
leesalminen
This, along with the ditching of MagSafe means I will not be purchasing MBPs
anymore. I know that nobody else has magnetic charging now. Hopefully someone
does before I have to upgrade.

~~~
eightysixfour
The Surface line uses magnetic chargers.

~~~
cgio
But terrible chargers they are. I had to replace mine twice once for my Pro
and once for Pro3. The cable bends very unnaturally and is gradually torn from
the magnetic connector. Other chargers have a driver piece of plastic where
the cable enters the connector that bends nicely to avoid this.

~~~
eightysixfour
Interesting, I had one SP3 do that but it was under recall. Wasn't aware it
was an issue with the older ones too.

~~~
rickyc091
Yep, it was an issue with the olds as well. I just wanted to link to this
instruction as the "proper" way to remove the charger. I found it hilarious.

[https://www.microsoft.com/surface/en-us/support/hardware-
and...](https://www.microsoft.com/surface/en-us/support/hardware-and-
drivers/battery-and-power?os=windows-10&=undefined)

------
orangea
Too bad there isn't a way to have your app control the touch bar even when it
isn't in focus. I would have liked to write a background application that
overrides it for personal use. I already have one that does that for the caps
lock key.

~~~
nerdponx
That's a nice idea, But I could only imagine it would lead to chaos as apps
start fighting each other for Touch Bar rights.

~~~
orangea
If I were in charge of Apple I'd make the app have to have accessibility
rights.

~~~
chrisseaton
How come? That seems like a totally unrelated access right to repurpose for
this?

~~~
madeofpalk
"Accessibility" is kind of the catch all super-permission to give to hooks
into greater parts of the operating system.

For example, Dropbox requires it for some features, as does an App that hides
menubar items.

------
tomelders
Is there any policy to prevent apps displaying ads in the touch bar?

~~~
gcr
Yes. From the API docs:

"""There is no need, and no API, for your app to know whether or not there is
a Touch Bar available. Whether your app is running on a machine that supports
the Touch Bar or not, your app’s onscreen user interface (UI) appears and
behaves the same way.

The Touch Bar dims automatically and wakes when the user touches it. Do not
show alerts in the Touch Bar, and do not use the Touch Bar for widgets."""

~~~
dahdum
Nothing stopping the developer from showing alerts or ads though right? Your
app might not know if it's enabled, but then again can just run 100% of the
time in case it is.

~~~
ams6110
I guess Apple not approving your app for the app store mught be a stopper.

~~~
statictype
Does it only work with App Store Apps?

~~~
Gaelan
Doubt it. Apple demoed it with Photoshop, and I doubt PS is going on the App
Store any time soon.

------
gniquil
So who's gonna be working on Sublime/Atom/Vim/Emacs integration on this. Shit,
imagine all the things one can do with that bar (multi-touch, slidable,
swippable).

~~~
wkirby
What can I do with the bar that I can't do with keyboard commands and my
multi-touch touchpad? Vim seems especially rough, with no physical escape key.
Guess I'll map that to caps lock?

~~~
gniquil
Increase/decrease font size, adjust window height/width. I know you can do it
with keyboard, but perhaps touch bar could make it more "natural" and free up
key bindings for something else. Escape can be mapped to a double width button
on the left.

~~~
wkirby
How is this better? I don't have to look at the keyboard to perform chords.
With no tactile feedback, I certainly have to look at the touch bar.

What's more, common actions usually have high-priority, simple chords
(cmd-c/cmd-v, for example) --- whereas complex chords are used for infrequent
commands (cmd-alt-shift-c to re-assign the origin in blender, for example). If
we're going to surface commands in the touch bar, intuition says to surface
the common commands, and leave infrequent ones tucked away, meaning that even
with the touch bar you don't have quick or simple access to those commands.

------
ben174
Looking forward to seeing if a web standard comes of this. Would love to be
able to make use of this additional UI in my web apps.

~~~
EpicEng
Please don't. I really don't want to be forced to look at my keyboard.

~~~
leesalminen
This seems like a developer-centric viewpoint. Users of my app are not tech
savvy and this could be a very convenient way of providing shortcuts to
things. We already offer customizable keyboard shortcuts but nobody uses them.

~~~
callalex
Ever heard of a UI element called the "toolbar"?

~~~
spiderfarmer
Why so condescending? The touchbar's sole reason for existing is for enhancing
productivity by making shortcuts discoverable.

------
cobbzilla
I like the idea of the TouchBar, but I just wish they would have kept a
physical escape key. As a heavy emacs user, I'm really going to miss it.

~~~
larme
A solution is use keychord[1] to map "`1" to ESC

[1]:
[https://www.emacswiki.org/emacs/KeyChord](https://www.emacswiki.org/emacs/KeyChord)

~~~
cobbzilla
so every 2-key meta command becomes 3 keys :/ keymapping is better than
nothing, though.

~~~
cwilkes
If you are a True Emacs User your fingers are already a twisted mess so this
shouldn't be that big of a stretch.

------
mthoms
If someone can figure out how to trick legacy MacBooks into displaying this
bar on the screen of a plugged in iPhone/iPad then you can take my money now.

There are so many old iPhone and iPads out there just waiting to be repurposed
for something like this.

Heck, I'd even be interested in a reasonably priced (< $150) external touch
strip as an accessory for my current MBP.

~~~
wingerlang
You might find this interesting [http://quadro.me/](http://quadro.me/)

~~~
mthoms
This exactly what I need, thank you!

------
metaprinter
is the touch bar accessible to folks using screen readers?

~~~
developer2
I can't see how they would even begin to make that possible. For the next
couple of years, the majority of MacBook users will not have a Touch Bar. This
means developers will only use it to duplicate functionality that is already
accessible in applications. You will not see features that are exclusively
found on the Touch Bar.

It is encouraging to read this in Apple's documentation[1]:

"There is no need, and no API, for your app to know whether or not there is a
Touch Bar available. Whether your app is running on a machine that supports
the Touch Bar or not, your app's onscreen user interface (UI) appears and
behaves the same way."

Skip forward 5 years to a time when software developers assume that every Mac
user has a Touch Bar. We will get to see just how poorly they make use of the
feature. Even as someone without any disabilities, I sincerely hope I am never
absolutely required to use the Touch Bar for features that cannot be found
elsewhere in an application.

[1]
[https://developer.apple.com/reference/appkit/nstouchbar](https://developer.apple.com/reference/appkit/nstouchbar)

~~~
madeofpalk
I would be shocked and surprised that it doesn't have the same VoiceOver APIs
available to make it accessible just like iOS.

------
emilong
> Such an instance is sometimes called, simply, a _bar_.

Kinda funny that a product that was only officially announced today already
has a vernacular. :)

~~~
jetpks
Probably the vernacular they've been using internally for the last year during
development.

------
ranman
So when will there be a WebKit API for this?

~~~
leesalminen
That was my first thought as well. Our product is browser based, and my
creative side is already swirling with possibilities.

~~~
lathiat
me too (worth a click, honestly :-):
[https://twitter.com/rdbaaa/status/791703609008205824](https://twitter.com/rdbaaa/status/791703609008205824)

------
ideamonk
TouchBar will play nice with digital audio workstations like Logic Pro / Live,
etc. I'll be happy to record pitch/mod/any VST param automations on a touch
strip.

DJ-ing apps could show up cue points and let you trigger them.

While fullscreen mode on macOS advocated distraction-free focus, TouchBar
takes a step backwards.

------
adomanico
Actually very pleasantly surprised that this version 1 API has this much
publicly customizable features. My guess was that this would be locked down in
the first new gen MacBooks

~~~
spiderfarmer
They have quite a few launch partners that probably gave them lots of
feedback.

------
tarikjn
I want a device API for third party keyboards, and a split toolbar more for
split keyboards. So that third party ergonomic keyboards can be developed
building on this.

------
increment_i
Interesting they gave it the legacy 'NextStep' prefix. Although I suppose it
makes sense given its a Mac-specific feature.

~~~
mittsh
AppKit + Foundation is always NS, UIKit always UI. But who cares now that we
have Swift ;)

~~~
nicky0
Everyone, because It's still NS and UI in Swift...

------
DarkByte
I wonder if the demonstrations had haptic feedback. If not, I wonder if we can
use NSHapticFeedbackPerformer to implement it.

~~~
daughart
The touch bar doesn't have haptic feedback.

------
tcper
Anyone noticed that this NSTouchBar API is not support Objective-C, it is
swift-only. Does it mean we would only code Swift for iOS/OS X some day?

~~~
panic
This is a link to the Objective-C API, which is why the "Objective-C" link is
disabled (you're already looking at it).

~~~
forgettableuser
I see where the confusion comes from.

The example in the middle is in Swift, regardless of which language you've
selected.

But the API list at the bottom does reflect your current language selection.

