Archive for the ‘How To’ Category

Apple Pencil: Too much information

I own a first generation refurbished Apple Pencil. I bought it when I picked up the new 5th gen iPad mini. It’s a delight. I use it for freehand note-taking when I don’t want to tip-tap into the onscreen keyboard or lug around my folding bluetooth keyboard. I use it doodle and draw. I use it to annotate PDFs. I especially love  how it knows what is the pencil and what is my hand so I can rest against the screen and still get work done.

My pencil keeps its charge for days with light use. When I need to top it up, I can stick it into my iPad’s lightning port. In under 10 minutes it goes from flatline to 100% charge. Yes, it looks a bit odd sticking out like that, but it isn’t for long and it’s easy enough to rest the iPad on a desk until the charge is complete.

Keep track of your current pencil charge in your iPad widget gallery. The Batteries  section shows how much juice is currently available:

When talking about charging, you should think about that tiny cap at the end of the first generation pencil. Fortunately, there are many extremely useful and inexpensive helpers for keeping track of the cap and the charging adapter, the short flat item at the bottom of this picture. It’s used for charging off a USB lightning cable by providing a female-to-female connector between the cable and the pencil:

Many third party gizmos service these tiny pieces. You can purchase replacement magnetic caps that better stick to your pencil and replacement charging adapters for when you lose them. If you’d rather not lose them in the first place, consider a simple holder set like this one. Mine is clear silicon and did not include the tip that covers the nib. The holders make sure the two tiny pieces aren’t easily lost, and that they’re kept along-side the equipment that uses them:

In addition, I purchased a magnetic sleeve to attach my pencil to my iPad and/or its smart cover when not in use. Again, this helps ensure I don’t lose the things I need. I roll the flat part away from my hand and find that it doesn’t interfere with holding the pencil or writing with it.

I use the Selvy PenScript keyboard plug-in to convert handwriting to text. It’s available from my normal keyboard. I tap-and-hold the globe to select it. Make sure when installing that you enable it in Settings > General > Keyboards.

As you see from this screenshot, I also installed the Kaomoji.HW keyboard that allows me to draw emoticons. It’s not very good at its job but it’s pretty hilarious to play with.

The SelvyPen keyboard is surprisingly useful across apps. It’s as easy to enter a URL as it is to type free text.

If you’re looking to enter large tracts of text by hand, Nebo does a great job with handwriting-to-text conversion, allowing you to enter information into notebooks using your pencil. Notice how the app keeps track of the ongoing interpretation in light gray just above the handwriting:

Use the ellipsis (3-dot) menu on the right to convert paragraphs to text and remove the handwriting entry. The accuracy is surprisingly good.

For annotating PDFs, I use Notability. I admit that it’s mostly because I already own it and it’s a great app. There are many other excellent options on the market. I’d love to hear what else you recommend. I apologize for all the blurring but I was reviewing someone else’s work and I wanted to respect their privacy:

For presentation, I have a half dozen apps of varying quality and I can’t really recommend one or the other as being particularly outstanding:

What other apps, tweaks, and gadgets have you found to enhance your pencil-using experience? I love my pencil and am always looking for more ways to get the most from it!

Reader recs:

  • Many readers agree with my use of Notability
  • Mike recs Concepts. “I use it as a vectorized infinite whiteboard for sketching and note taking.”
  • Teddy likes GoodNotes, “which will hide the UI when projecting to an external screen. Also has a nice laser pointer with a trail so you can make temporary markings as you go” and PDF Viewer for annotation.
  • Paper by WeTransfer gets a thumbs up from Paul.

Trackpad dragging the easy way

I’m surprised it took me as long as it did to discover that there’s an accessibility alternative for dragging. In System Preferences, visit Accessibility > Pointer Control > Mouse & Trackpad.

Click on Trackpad Options, enable dragging, and choose three finger drag from the pop-down.

I’ve been using three finger dragging for about a week now and it’s been a vast improvement over my attempts to drag items the normal way. Yes, I still end up running out of trackpad room as I always do, but using a finger from the other hand to nudge things where they need to go does the trick for getting my dragged items to their destinations.

I am using this almost entirely in Finder, although the same approach should work for moving words in a document or views in IB.

Mac Dictation 101

Dictating to text is one of the great things that macOS gave us a few years ago. In both Mojave and Catalina, you enable dictation in System Preferences in the Keyboard > Dictation Pane.

I use the “double-command” shortcut to enable dictation but I also find it helpful to set up the Mac version of “Hey Siri”. To start, hop over to Accessibility > Dictation (Mojave) or Accessibility > Voice Control (Catalina) to extend your interaction. Enable dictation or voice control, as supplied. On Catalina, you may need to download additional elements which takes a moment or two.

In Mojave, you can set a dictation keyword. I go with “Computer”, because it sounds very Scotty from Star Trek TOS. I prefer to enable sound feedback so I know when my command has been picked up properly.

To ask Siri about the weather, I say, “Computer. <beat> Open Siri. <wait for tone> What is the weather for today?”. There’s a definite pause needed after “Computer”.

Catalina offers an always-on version when you enable voice control.

This little control panel lets you sleep or wake your mike:

Once in place, you can say “Open Siri”.  Confirm that you want to enable Ask Siri and you know that employees or contractors somewhere — I believe it was Ireland — will be laughing at you, but privacy is an illusion these days. Search for articles similar to “Apple Resumes Human Reviews of Siri Audio With iOS 13.2 Update” for more details. As with Mojave, you’ll need to develop separate dialects for iOS and Mac for controlling your system, with significant pauses to let the OS catch up with you.

Always-on dictation seems to send my MBP into windtunnel spasms, so you may want to use those keyboard shortcuts instead.

Once on, you can request “What can I say” and a list of commands pops up. It’s pretty basic and uninspiring as a support doc goes but it’s a start and the commands are quite extensive.

For example, say “Open TextEdit <pause> New item (assuming you don’t have TextEdit setup to create one on launch).”

Next, try dictating. I recommend opening a browser tab apart from TextEdit and just speak from a reference document. For example:

Listen my children and you shall hear
Of the midnight ride of Paul Revere,
On the eighteenth of April, in Seventy-five;
Hardly a man is now alive
Who remembers that famous day and year.

You’ll immediately see some of the weaknesses involved in dictation.

Starting over, I’ve used some dictation-fu. For example, when “here” is mispelled, I used “correct that” and “choose 1”.

“New line” gets me to the second line. “Select word” highlights the most recent and “Capitalize that” changes “revere” to “Revere”. The next line after that is just ridiculously hard. I’ll leave that one as an exercise for the reader. Finish it off with “semicolon. press Return key”.

The rest is easy, particularly because TextEdit did the uppercasing on my behalf. Don’t forget to insert a new line and say “period” (Or, I suppose, full stop. Hi Paul.) at the end of the sentence.

As with iOS, Catalina appears to be using a scaled down version of Dragon Dictation so it’s always helpful to be able to use the Dragon documentation, even when you run up against some pretty hard edge cases.

It’s honestly not the worst dictation system but I prefer the one on iOS.

 

 

 

Fun with Xcode Search Domains: Excluding match text

Most Xcode users quickly become familiar with the basics of the Find Navigator panel.

With it, you can find text, regular expressions, and perform search-and-replace, whether matching or ignoring case. But that’s just scratching the surface of the Find Navigator.

I thought I’d drop a few words today about search scopes. Controlled from the bottom left,  under the search field, you can create narrowed searches. This enables you to, for example, search only in Swift files or exclude files containing the word Test.

To get started, click the icon (two lines with three squares on a line between them) and then New Scope (the plus icon). Here, you can name the scope, limit the search extent, and add criteria for exactly which files should be included or not.

The logic is straightforward. You choose where to look (the project, a folder, or through the entire SDK), and whether to include all conditions or some conditions:

Each condition is based on the file name, path, extension, UTI (the kind of file, like image which is useful for finding vector assets), Workspace location (namely groups), or source control status (handy for finding newly applied changes.)

Most of my conditions are file-name-based. And for those, you get the following matching conditions. The “ends with” is an obvious win for extensions (although you can also use UTIs for that), and “starts with” can help for projects organized in hierarchical ways.

Now, interestingly enough, this list fails to offer “does not contain” but that’s fairly easy to work around. Since Xcode supports regex matching, you can easily replicate “does not contain” with an appropriate regex:

Change the file name to a path to exclude source file directories.

You can create as many search domains as you like. At least, I haven’t found an upper bound yet. I haven’t found a way to reorder the find scopes, although if you’re really controlling about this, you can pop into  your workspace (ProjectName.xcodeproj/project.xcworkspace/xcuserdata/username.xcuserdatad), convert your UserInterfaceState.xcuserstate to xml (plutil -convert xml1), and hand-edit it the way you need.

There are lots of wonderful little Xcode tweaks like these throughout this monster of an IDE. What are some of your faves? If I have time this week, I’ll share some of mine, such as the four-square — another of my favorite tools — and a few great ways to connect your editor to the navigator.

WebsearchFodder: My mouse moves but won’t click

Weirdest thing this morning. My mouse stopped working right. I could move the cursor but not click the mouse. So I swapped it out for another mouse. Same problem. So I rebooted. Same problem. I then switched to a wireless mouse and then a Bluetooth one. Same problem across the board.

I won’t make you sit through all the problem solving that went on: same issue meant that this was not a mechanical error, and not tied to, for example, specific wires, or bulging batteries or whatever. The tl;dr is this: I had taken out a magic trackpad a few hours earlier, intending to use it (but never got around to it), and left it on a counter and a child had put something on top of it.

The magic trackpad had not only powered on but was continuously, due to the weight, issuing some sort of mouse press because of the weight of the stuff dumped on top of it. Once I took the weight off, everything started working again back at my computer.

Diagnostically: the cursor moves, any right-button works, any scroll wheel works, but not the left-button. Solution: hunt around for a wireless pointing device that might be interfering. If you have Screen Sharing enabled, you can disable Bluetooth and see if that resolves the problem.

I took the batteries out of the trackpad, and put it away gently.

I’m leaving this blog post in case it ever helps anyone else out on this very weird issue. The advice out there on the web all assumes a mechanical issue either with a built-in trackpad, with a pointing device, or a system issue. This was such a sideways situation that surely I can’t be the only person it will happen to but it probably most everyone will never be affected.

Good Things: SwiftUI on Mojave in iOS Playgrounds

Yes, you can upgrade to the Catalina Beta. Or, you can keep getting work done on Mojave and still enjoy the glory of SwiftUI exploration.

  1. Install Xcode 11 beta along side your 10.2.x Xcode
  2. Using the beta, create an iOS playground. (This won’t work with macOS, which attempts to use the native frameworks, which don’t  yet support SwiftUI)
  3. Import both SwiftUI and PlaygroundSupport.
  4. Set the live view to a UIHostingController instance whose rootView conforms to View.

Here’s an outline of the basic “Hello World” setup:

From there, you can create pages for each of your SwiftUI experiments, allowing you to build short, targeted applets to expand your exploration and understanding of the new technology.

Return to Sender: My first dive into watchOS

Just wrote my first two watchOS apps. The first, intended to provide voice coaching for physical therapy exercises, was a failure. Timing just wasn’t reliable and the errors built up more and more over a session of repeated counts, holds, and “almost there”/”two more”/”last one” prompts.

The second was a simple D&D dice set and much more successful. (Barring, of course, my miserable sense of interface design.)

It consists of an iOS app paired with a watchOS extension, which runs as its own watchOS app, allowing anyone with an arm and a need for d20 to roll at will.

The WatchOS APIs were disappointing at first glance. For one thing watch buttons use target-action but provide no sense of sender. A single iOS call must be split into 7 calls on the watch:

// iOS. I used tags. Sue me.
@IBAction func roll(_ button: UIButton) {
    let value = Int.random(in: 1 ... button.tag)
    let percent = button.tag == 100 ? "%" : ""
    label.text = "\(value)\(percent)"
}

// watchOS
@IBAction func d4()  { label.setText("\(Int.random(in: 1...4))")  }
@IBAction func d6()  { label.setText("\(Int.random(in: 1...6))")  }
@IBAction func d8()  { label.setText("\(Int.random(in: 1...8))")  }
@IBAction func d10() { label.setText("\(Int.random(in: 1...10))") }
@IBAction func d12() { label.setText("\(Int.random(in: 1...12))") }
@IBAction func d20() { label.setText("\(Int.random(in: 1...20))") }
@IBAction func dPercent() { label.setText("\(Int.random(in: 1...100))%") }

There’s no auto-layout so far as I can tell, so you either “fill” things or you give them fixed sizes. I couldn’t figure out a way to split my buttons into thirds of the available screen space.

Setting a label’s text is a matter of a function call not a property assignment. That was surprising to me. I’m not sure what advantage was gained here beyond violating the principle of least astonishment.

I had to design my app’s interface in the WatchKitApp target but implement it in the extension target. This may be perfectly normal and in-line with other extensions on iOS but I haven’t spent much time there so it raised my eyebrows a bit. You add your app assets in the app, your complications (which I did not build) in the extension.

Right now on my priority list, I’d like to build something similar to the “breathe” app. I don’t entirely know where to start. I need to use a notification system to launch the app at set intervals, n times a day, preferably during the work day, and then use some kind of coached interaction with haptic feedback. My immediate goal is one that has me regularly exercise my sitting back muscles to build up strength.

I’m a bit sad about the timing issues I encountered with my first jab at the coaching app. I may approach that again with a new design as having my wrist count and prompt would be a lot better than having to do all the work myself (I always lose my place) or having to keep my phone nearby.

My need for reps, holds, and rest periods are simple. And while I don’t particularly like the scrolling wheel that seems to take the place of segmented controls, I can live with them.

If you’d like to see my first project (either to be inspired or to offer critiques), I’ve left a copy at github.

Making @KeyboardMaestro work in Mojave

Unfortunately, Apple seems to have messed up assistive apps like Keyboard Maestro in Mojave and if you depend on macros, that’s a very bad thing indeed. I upgraded to Mojave late last week (even though it is still not theoretically a GM) and found that although some actions still worked without problem like app launching others (specifically my universal Emacs key equivalents for arrow moves) did not.

I found this thread about the issue on a Keyboard Maestro forum. The hints on that thread helped me work out this solution to the Mojave problem. Note that you may have to repeat steps after rebooting your Mac.

  1. Copy /Applications/Keyboard\ Maestro.app/Contents/MacOS/Keyboard Maestro Engine.app to /Applications.
  2. In Terminal, kill the Keyboard Maestro and Engine processes.
  3. Open System Preferences > Security and Privacy > Accessibility. Grant privileges to both apps: Maestro and the copied Engine. (I also granted privileges to Finder and Safari, which probably wasn’t necessary.)
  4. Launch the Engine from /Applications. Check the process list for /Applications/Keyboard Maestro Engine.app/Contents/MacOS/Keyboard Maestro Engine and test your macros. You may have many types of macros and you’ll want to hit as many bits of the OS as possible when ensuring that each kind of macro is properly launched and executed.

 

Better table processing

Thanks to Andy Lester:

#! /bin/sh

# Process pasteboard contents to md table. Thanks, Andy Lester.
# Copy table from Numbers or other tab-delimited spreadsheet.
pbpaste | perl -le'$_=<>;&x;s/[^|]/-/g;&x;for(<>){&x}sub x{chomp;s/\t/|/g;print"|$_|";}' | pbcopy

# Done.
echo "Styled pasteboard to table"