rosscarter.com

Cocoa

14 August 2008 | No Comments

NSString -characterAtIndex:

I posit that there is no such thing; that is to say, characterAtIndex: will return a unichar value that might or might not represent the encoding of a character.
Read more »

9 August 2008 | No Comments

StandardKeyBinding.dict and private API

Evidently this is not a problem for most developers, but I have run into a snag caused by AppKit’s failure to declare methods that are specified in /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict.
Read more »

26 May 2008 | No Comments

Leopard autoregisters transformers?

I created a new NSValueTransformer and used it in a nib binding, referring to it by the class name. I forgot to register it. When I ran the app, I did not receive a “could not find transformer named…” error; instead, the transformer worked perfectly.

How can that be? I didn’t write any code to instantiate the transformer. The application delegate imports the header for the transformer. Hmm. Could it be that Leopard, when it can’t find a registered transformer of a given name, will try to initialize one using the className?

Wish I had more time just now to experiment.

22 March 2008 | No Comments

Tooltips are now temporary attributes

I just noticed this Leopard goodie. In Tiger, the documentation for the NSLayoutManager method -(void)addTemporaryAttributes:forCharacterRange: said, “Currently the only temporary attributes that will be recognized are those related to colors and underlines.”

In Leopard it reads, “Currently the only temporary attributes recognized are those that do not affect layout (colors, underlines, and so on).”

That “and so on” points to a nice enhancement: you can now specify tooltips as a temporary attribute. This means you can have the typesetter add a tooltip in the middle of typesetting; the NSTextStorage doesn’t need to know anything about it.

As a bonus, there’s a new method – (void)addTemporaryAttribute:value:forCharacterRange:.

Thanks, Douglas Davidson.

18 March 2008 | No Comments

Who came up with that interface? A Windows programmer?

Today’s local paper, describing a vote fraud prosecution in Clay County, Kentucky:

The county had new voting machines for the May 2006 election. The machines had a “Vote” button that allowed people to review their choices, but they had another button marked “Cast” to actually record the selections and finish voting.

Read more »

16 November 2007 | No Comments

Stacks: the solution

My little DockAppsMenu worked to restore the functionality of a hierarchical Applications menu in the Dock as a temporary solution until something better came along. It’s now here: Quay by Rainer Brockerhoff.

I’ve been trying out the beta and I can’t wait to send him seven euros for the release version as soon as it’s available. Quay gets it right. Folders sit in the right side of the Dock and look exactly as they do in a standard Leopard setup. But a click (not a right-click) reveals a hierarchical menu rather than those hideous Stacks. Read more »

29 October 2007 | 23 Comments

Leopard Stacks and the Applications folder

Important update: There are now two proper solutions to the Stacks fiasco. Either install the 10.5.2 update or install Quay. You do not need to use my application.

Leopard arrived with one major irritation: you can no longer drag a folder to the Dock and have its contents appear in a popup menu. This bugged me so much I couldn’t enjoy any of the great new features. So I whipped up a workaround to use until somebody comes up with a better idea.
Read more »

7 July 2007 | No Comments

NSTextContainer setContainerSize

I have some NSTextView subclasses that can be resized vertically. Following the advice of TextSizingExample in the AppKit examples, after [textView setVerticallyResizable:YES] I set the textView’s textContainer height to 1.0e7.

This caused a strange problem: the typesetter would not advance to the next container when it encountered a control glyph with the action NSTypesetterContainerBreakAction.

After an hour or two of consternation I tried setting the container height to 1.0e6 and the typesetter now handles the container breaks just fine.

2 July 2007 | No Comments

Views in drawers: finding the parent window

I have a subclass of NSTextField that needs to listen for notifications whose object is the main document window. When the textField is in a toolbar, this is easy; [self window] returns the document window, so I just set the textField to observe notifications from its window. But when the textField is in a drawer, [self window] returns an instance of NSDrawerWindow, a private class. There’s no direct way to go from the NSDrawerWindow reference to the main window without using undocumented calls. And there’s no method in NSDrawer that returns its NSDrawer window. Read more »

1 July 2007 | 3,611 Comments

Should GUI designers think about color blindness?

My answer: not unless they are color blind.

But you and I might see things differently.

These are the opinions of a deuteranope. I reject the term color-blind because I am not blind in any sense. My life is as rich and wonderful as that of anyone; I can see bright and varied colors, meaningful and beautiful colors. But my eyes are deemed “green weak” and indeed my color perception is impaired in a few ranges.

So what? Read more »