Categories
.

“Select-All” after clicking in an NSTextField

I had been looking for a way to automatically select-all when a user clicks in an NSTextField. By default, the convention in OS X is to put the insertion point where the user clicks (assuming the textfield is editable). After much googling and trial and error I eventually subclassed NSTextField, then overrode mouseDown. I actually put nothing in the method, and yet achieved the desired results. I simply reassigned my NSTextFields in my XIB to be of my subclassed type and suddenly it worked as I desired.

MainMenuStringFixer

I found that I needed to think of a better way to localize my NIBs. I was looking to potentially create some new panes and didn’t want to have to go back through each language’s NIB file and hand tweak those. I Googled around and came across Will Shipley’s excellent article “Lost In Translations”

I will not repeat what he’s written there however I found that his instructions lacked one thing that I already had and needed an additional step for: I needed to grab any of the translations that I already had done and pull them out to a MainMenu.strings file. That was actually easy enough to do with ibtool however the files that are generated come out like

/* Class = "NSTextFieldCell"; title = "Aufgabe:"; ObjectID = "741"; */
"741.title" = "Aufgabe:";

As a reminder I needed to end up with a MainMenu.strings file (in each .lproj) that looked more like this:

"Task:" = "Aufgabe:";

So what I did was modify the mainMenuStringAdapater.m file so that it stores the ObjectID and key text from the English (in my case) MainMenu.strings file, then loads the language-to-be-translated’s-MainMenu.strings file  (passed as parameters) and saves a resultant file out with the corrected MainMenu.Strings file for that language, without the objectIDs as keys.

You should definitely look over the resultant file and confirm that it did what it was supposed to. Additionally It should also dump out a file telling you how many lines were in each MainMenu.strings file and if there were any ObjectIDs in the foreign file that were not accounted for from the English file (and therefore need to be handled in the fixed version).

This was a quick and dirty job and I’m sure there are leaks and such, but I figured it might do someone else some good so I’m sticking it up here.

Categories
.

Gammalowski

I call Monti “Gums” or “Gummalowski” or “Gumby”

She doesn’t like to sleep with just me.. Cries like crazy when E goes to the bathroom.

She likes to use her fork… Likes to stab potatoes and eggs. And when done she throws it on the ground.

I am working on the SchottenServer stuff. Elsa helping but worrying about gifts for Xmas. I’ve been loading games up on my XBox.