My colleague, Alex Sursiakov, wrote an excellent blog post on the Touch Bar™. In his post, Advanced Touch Bar Customization with Parallels Desktop, Alex detailed an advanced way to implement Touch Bar button sets, which gives the user many additional design options that are not available using the Touch Bar customization features built into Parallels Desktop® 13 for Mac. This additional power, however, comes at a price: You have to write XML code to describe the Touch Bar button set, unlike the easy, drag-and-drop Touch Bar customization tool in Parallels Desktop 13.
I decided to try out this advanced approach. After several false starts and a little bit of cursing, I was able to implement a wild and crazy Touch Bar. (See Figure 1.)
Here is the XML code that implements this Touch Bar:
<TouchBar id=’notepad++’ defaultItemIdentifiers=’button1,button2,NSTouchBarItemIdentifierFixedSpaceLarge,button3,button4,button5,NSTouchBarItemIdentifierCharacterPicker’>
<Button id=’button1′ keyCode=’alt+f4′ title=’This’ backColor=’FC1D00′ textColor=’FFFFFF’/>
<Button id=’button2′ keyCode=’alt+f4′ title=’is’ width=’90’ backColor=’FFFB00′ textColor=’000000’/>
<Button id=’button3′ keyCode=’alt+f4′ title=’ ‘ width=’30’ image=’NSTouchBarColorPickerFont’ backColor=’00FC1D’ textColor=’000000’/>
<Button id=’button4′ keyCode=’alt+f4′ title=’Wild and Crazy’ width=’190′ image=’NSTouchBarColorPickerFill’ backColor=’4B9454′ textColor=’000000’/>
<Button id=’button5′ keyCode=’alt+f4′ title=’Touch Bar!’ width=’160′ backColor=’FA7602′ textColor=’FFFFFF’/>
This code probably won’t mean much to you if you haven’t already read Alex’s post.
Figure 2 shows this code in my Windows 10 virtual machine.
Some notes about my experience:
- Even the most seemingly trivial typo will make this not work. Once I mistyped ‘defaultItemIdentifiers’ and got no Touch Bar at all. Finding that typo was not easy.
- Alex told readers that when you make a change to the XML, you need to reboot the VM. This is always a good idea, but not always completely required. After saving the XML changes, it is easy (and probably not dangerous) to just switch the foreground application and then switch it back to the application you are designing the Touch Bar for—just click on the Windows Desktop and then click back to your application window. As fast as Parallels Desktop now is for rebooting Windows, two mouse clicks are still faster.
- Sometimes applications will “help” you by automatically adding a file type to any file name you enter. In the case of the file you name as “notepad++.exe.xml”, this might result in the file being named “notepad++.exe.xml.xml”. For the advanced Touch Bar customization work, a file name like this will not You will have to ensure that the application does not add anything to the file name.
- Sometimes text-processing applications will automatically change all quotation marks into typographically correct quotes (also sometimes called “curly quotes” or “smart quotes”). In ordinary text, this is usually correct. For computer code (HTML, XML, or programming language text), this is usually incorrect and will prevent your code from working as expected. If you see this conversion taking place when you are typing any code, make sure you turn off the autocorrect feature.
- If you use a text processor which “understands” XML and the color and formatting don’t look like Figure 2, then you probably have a typo somewhere in your code.
Learning a little about XML and implementing a Touch Bar button set in XML gives you a lot more power. But as Spiderman’s Uncle Ben once said:
With great power comes great responsibility.
My next task is to design and implement a useful Touch Bar button set for some Windows application. Stay tuned.
Interested in customizing the Mac Touch Bar for Windows programs in Parallels Desktop? Get started with our 14-day free trial.