From 61cb6c09e2f2ff5b723014ef54d341cec6394c27 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sun, 14 Aug 2011 23:56:35 +0200 Subject: [PATCH] Fix nasty mouse-over bug with NSTokenFieldCell --- Medianno.xcodeproj/project.pbxproj | 6 ++++++ Medianno/MADocWindow.mm | 3 ++- Medianno/MATokenFieldCell.h | 13 +++++++++++++ Medianno/MATokenFieldCell.mm | 23 +++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Medianno/MATokenFieldCell.h create mode 100644 Medianno/MATokenFieldCell.mm diff --git a/Medianno.xcodeproj/project.pbxproj b/Medianno.xcodeproj/project.pbxproj index 2a83f39..b0a6a75 100644 --- a/Medianno.xcodeproj/project.pbxproj +++ b/Medianno.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 950BB7A713F467A400D8E669 /* MAAddMedia.xib in Resources */ = {isa = PBXBuildFile; fileRef = 950BB7A513F467A400D8E669 /* MAAddMedia.xib */; }; 950BB7AA13F46BAF00D8E669 /* MAAddMediaSheet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB7A913F46BAF00D8E669 /* MAAddMediaSheet.mm */; }; 950BB7AD13F46ECF00D8E669 /* MAAppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB7AC13F46ECF00D8E669 /* MAAppController.mm */; }; + 95B3748713F87B17009BB79A /* MATokenFieldCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95B3748613F87B17009BB79A /* MATokenFieldCell.mm */; }; 95BCFA2113F76A04000F650F /* app.icns in Resources */ = {isa = PBXBuildFile; fileRef = 95BCFA1F13F76A04000F650F /* app.icns */; }; 95BCFA2213F76A04000F650F /* doc.icns in Resources */ = {isa = PBXBuildFile; fileRef = 95BCFA2013F76A04000F650F /* doc.icns */; }; 95C534E013F732A200A07932 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 95C534DE13F732A200A07932 /* Localizable.strings */; }; @@ -63,6 +64,8 @@ 950BB7A913F46BAF00D8E669 /* MAAddMediaSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MAAddMediaSheet.mm; sourceTree = ""; }; 950BB7AB13F46ECF00D8E669 /* MAAppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAAppController.h; sourceTree = ""; }; 950BB7AC13F46ECF00D8E669 /* MAAppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MAAppController.mm; sourceTree = ""; }; + 95B3748513F87B17009BB79A /* MATokenFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MATokenFieldCell.h; sourceTree = ""; }; + 95B3748613F87B17009BB79A /* MATokenFieldCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MATokenFieldCell.mm; sourceTree = ""; }; 95BCFA1F13F76A04000F650F /* app.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = app.icns; path = Resources/app.icns; sourceTree = ""; }; 95BCFA2013F76A04000F650F /* doc.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = doc.icns; path = Resources/doc.icns; sourceTree = ""; }; 95C534DF13F732A200A07932 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; @@ -175,6 +178,8 @@ 950BB7AC13F46ECF00D8E669 /* MAAppController.mm */, 950BB78413F2D95500D8E669 /* MADocWindow.h */, 950BB78513F2D95500D8E669 /* MADocWindow.mm */, + 95B3748513F87B17009BB79A /* MATokenFieldCell.h */, + 95B3748613F87B17009BB79A /* MATokenFieldCell.mm */, ); name = Classes; sourceTree = ""; @@ -258,6 +263,7 @@ 950BB78613F2D95500D8E669 /* MADocWindow.mm in Sources */, 950BB7AA13F46BAF00D8E669 /* MAAddMediaSheet.mm in Sources */, 950BB7AD13F46ECF00D8E669 /* MAAppController.mm in Sources */, + 95B3748713F87B17009BB79A /* MATokenFieldCell.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index f839c56..1dcac87 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -12,6 +12,7 @@ #import "MAAddMediaSheet.h" #import "MADocument.h" #import "MAAnno.h" +#import "MATokenFieldCell.h" @implementation MADocWindow @@ -28,7 +29,7 @@ [mediaController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES]]]; [annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]]; NSTokenFieldCell * tokenCellProto = [tokenFieldProto cell]; - NSTokenFieldCell * tokenCell = [[NSTokenFieldCell alloc] init]; + NSTokenFieldCell * tokenCell = [[MATokenFieldCell alloc] init]; [tokenCell setDelegate:self]; [tokenCell setFont:[tokenCellProto font]]; [tokenCell setTokenizingCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@";"]]; diff --git a/Medianno/MATokenFieldCell.h b/Medianno/MATokenFieldCell.h new file mode 100644 index 0000000..e37759e --- /dev/null +++ b/Medianno/MATokenFieldCell.h @@ -0,0 +1,13 @@ +// +// MATokenFieldCell.h +// Medianno +// +// Created by Matthias Neeracher on 8/14/11. +// Copyright 2011 Matthias Neeracher. All rights reserved. +// + +#import + +@interface MATokenFieldCell : NSTokenFieldCell + +@end diff --git a/Medianno/MATokenFieldCell.mm b/Medianno/MATokenFieldCell.mm new file mode 100644 index 0000000..dde3c07 --- /dev/null +++ b/Medianno/MATokenFieldCell.mm @@ -0,0 +1,23 @@ +// +// MATokenFieldCell.mm +// Medianno +// +// Created by Matthias Neeracher on 8/14/11. +// Copyright 2011 Matthias Neeracher. All rights reserved. +// + +#import "MATokenFieldCell.h" + +@implementation MATokenFieldCell + +- (void)updateTrackingAreaWithFrame:(NSRect)cellFrame inView:(NSView *)controlView +{ + // + // Sorry for this horrible hack. We override this so our superclass doesn't get it. + // If it does, and -[NSTableView updateTrackingAreas] is called while this cell is + // selected, it will set up a tracking area covering the entire table view, with + // nasty consequences. Ignoring the call doesn't seem to have adverse consequences. + // +} + +@end