Introduction

KFTypeSelectTableView adds the type-select, or type-ahead, feature to table views. When a table has keyboard focus,
  • Typing a few characters selects a matching table row.
  • ^↓ and ^↑ and select next and previous match.
  • ESC and ⌘. cancel.
As a user, I'd like all apps to support this feature, so I'm trying to write a class that there isn't any reason not to use. It doesn't require any configuration unless you're using bindings, and it's BSD licensed. Even when you do want to configure behavior, almost all logic stays in the subview class. You can pose with it and get type-select in all tables (and outline views too!).

Be sure to check out the included sample code. There's a plugin for Mail.app, and a SIMBL module that adds type-select to every tableview system wide.

Requirements

Not a whole heck of a lot. Only tested on 10.3 at the moment, but there are no obvious dependencies past 10.0.

Usage

KFTypeSelectTableView.h documents the API. There are also four sample targets, three of which are arguably useful programs.
  • The Demo target is a basic demonstration. It does a bit of configuration and gives some feedback. Uses bindings, so requires 10.3.
  • The MailPlugin target builds this Mail .app plugin. The plugin adds type-select to the main message table in Mail and gives more thorough feedback than the Demo target demonstrates. It's also a simple example of a Mail plugin. See here for installation instructions.
  • The PulpFictionPlugin target is like the Mail target, but the plugin is for PulpFiction and PulpFiction Lite. This demonstrates the extra step required for tables that use bindings for data. It uses SIMBL to load, so go install SIMBL if you don't already have it for PithHelmet. To install the bundle, copy it to ~/Library/Application Support/SIMBL/Plugins.
  • The GlobalPlugin target is.. interesting. It builds a bundle that makes KFTypeSelectTableView pose as NSTableView in any app it loads into. In other words, if you load it into everything, then all non-bindings cocoa table views in Mac OS X gain type-select. It's useful, and I know of no cases where this negatively impacts an app's existing features. Still, not every application is set up so that type-select works as you'd hope. In Keychain.app, for example, the detail pane doesn't update when the table selection changes.

    This is also a SIMBL plugin, so install SIMBL and put this bundle in ~/Library/Application Support/SIMBL/Plugins.

    Always make clean when switching to or away from this target. There are some #defines explained in GlobalCompatibilityPrefix.h.

    Also, note that you can use the defaults key "KFTypeSelectTableViewMatchAlgorithm" to control whether matches are made by prefix or by substring in individual apps.

Bugs and Limitations

  • A table view that uses bindings for data requires some configuration before type-select will work. There isn't any documented way to get data for such a table.
  • Dead keys (like option-e on a US keyboard) don't timeout. The sequence "option-e", wait three seconds, "e" searches for an "é" character.

Changelog

Version 1.0.4, 4/16/2005:
  • The delayed message that clears the input buffer can no longer can extend the life of the tableview. In Adium, a pending delayed message could keep the table alive past the lifetime of its delegate, which led to a crash.
  • More careful about the use of +load in plugins.
Version 1.0.3, 3/8/2005:
  • New optional search wrapping API.
  • We now call tableView:shouldSelectRow: to check if a match should be accepted before selecting it. Same goes for selectionShouldChangeInTableView: (before starting type-select) and the related methods for outline views.
  • Improved peak memory usage. This is only important for very large tables.
  • Changed default match style to match prefixes instead of substrings. I think I'm the only one who always expects substring. Can still set a default to change style globally, or message an instance to change style for that object.
  • Fixed bug preventing call to configureTypeSelectTableView: when object is an NSOutlineView (only possible with posing).
  • Now call delegate's willDisplayCell: method when getting data for a cell. Some table delegates modify cell value in that method. It is still necessary to implement typeSelectTableView:stringValueForTableColumn: if cell never has a meaningful string value.
Version 1.0.2, 2/24/2005:
  • Improved scroll behavior for tables with horizontal scrolling.
Version 1.0.1, 2/24/2005:
  • Corrected a mistake affecting editable tables.
Version 1.0, 2/23/2005:
  • Changelog baseline

License

KFTypeSelectTableView is distributed under the "BSD" license:
Copyright (c) 2005, Ken Ferry
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither Ken Ferry's name nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Contact

Email me at user kenferry, domain mac.com.

Comments, bugs, suggestions, contributions, and anything else I missed are welcome. I'd appreciate a note if you use the class for something. Enjoy!

last modified: 3/8/2005