Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Anton Barkov: Developing for Touch Bar

Anton Barkov: Developing for Touch Bar

MacPaw Tech Talks

November 26, 2020
Tweet

More Decks by MacPaw Tech Talks

Other Decks in Programming

Transcript

  1. What we’ll talk about • What’s a Touch Bar •

    Adding Touch Bar support in your macOS app • Fun little hacks 3
  2. What’s a Touch Bar • Standalone device • Run by

    T1 SoC chip, ARM architecture • Modified watchOS (eOS?) • USB connection to macOS • Only 25MB of memory - no movies on touch bar for you 8
  3. What’s a Touch Bar • Retina display • Size: 2170x60

    pixels • Optional system button • App specific controls • System controls in the Control Strip 9
  4. 15

  5. Adding Touch Bar Support What is an NSTouchBar An object

    that provides dynamic contextual controls in the Touch Bar. 18
  6. Adding Touch Bar Support How it works First responder changed

    System asks the first responder for an NSTouchBar First responder provides touch bar with makeTouchBar() method 19
  7. Adding Touch Bar Support A UI control shown in the

    Touch Bar. What is an NSTouchBarItem 24
  8. Adding Touch Bar Support Adding and item to NSTouchBar •

    Provide an NSTouchBar with makeTouchBar() • Specify identifiers of items you want to output on the Touch Bar • Provide the items in the NSTouchBarDelegate method 27
  9. Adding Touch Bar Support Other controls Spotify: Telegram: Sketch: All

    of the controls are implemented in detail in the Apple sample Touch Bar project: 32
  10. What about the demo? • How do we show our

    touch bar when the app is not active? • How do we show our touch bar ignoring the control strip? • How do we observe the event of a Mac being unlocked? 38
  11. Fun little hacks Other hacks - add control strip item

    Private DFRFoundation.framework NSTouchBarItem private class methods 52
  12. Conclusions • Touch Bar is cool • Sometimes impossible things

    are not that impossible • Anything can be a touch bar item! 58
  13. Thank you! Anton Barkov - macOS Software Engineer @ MacPaw

    Telegram: @anton_barkov Facebook: /ton.barkov LinkedIn: /in/a-barkov Apple sample Touch Bar project 59 Our YouTube channel My GitHub