Make "Run Specs" menu item w/ key equivalent.

This commit is contained in:
Nathan Sobo
2011-12-16 15:04:12 -08:00
committed by Corey Johnson & Nathan Sobo
parent 30adef91fc
commit ff57cbc8f6
3 changed files with 64 additions and 22 deletions

View File

@@ -7,5 +7,6 @@
@property (nonatomic, retain) NSMutableArray *controllers;
- (void)removeController:(AtomController *)controller;
- (IBAction)runSpecs:(id)sender;
@end

View File

@@ -16,9 +16,8 @@
[self.controllers addObject:controller];
}
- (AtomController *)createSpecController {
AtomController *controller = [[AtomController alloc] initForSpecs];
return controller;
- (IBAction)runSpecs:(id)sender {
[[AtomController alloc] initForSpecs];
}
- (void)removeController:(AtomController *)controller {
@@ -36,23 +35,12 @@
- (void) sendEvent: (NSEvent *)event {
// Default implementation for key down tries key equivalents first
// We want to wait until the web view handles the event, then allow key equivalents to be tried
if ([event type] != NSKeyDown) {
if (([event type] != NSKeyDown) || !event.window) {
[super sendEvent:event];
return;
}
// TODO(NS): Make running specs a menu command with a key equivalent, so we can delete this code
BOOL shouldRunSpecs =
([event type] == NSKeyDown) &&
([event modifierFlags] & (NSAlternateKeyMask | NSControlKeyMask | NSCommandKeyMask)) &&
[[event charactersIgnoringModifiers] hasPrefix:@"s"];
if (shouldRunSpecs) {
[self createSpecController];
return;
}
[[event window] sendEvent:event];
[event.window sendEvent:event];
}
- (void)terminate:(id)sender {
@@ -72,7 +60,7 @@
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
[self createSpecController];
[self runSpecs:self];
}
@end

View File

@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1938</string>
@@ -61,6 +61,15 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="208934156">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Run Specs</string>
<string key="NSKeyEquiv">s</string>
<int key="NSKeyEquivModMask">1835008</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="304266470">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
@@ -753,6 +762,14 @@
</object>
<int key="connectionID">536</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">runSpecs:</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="208934156"/>
</object>
<int key="connectionID">541</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">print:</string>
@@ -1398,6 +1415,7 @@
<reference ref="1046388886"/>
<reference ref="1056857174"/>
<reference ref="342932134"/>
<reference ref="208934156"/>
</array>
<reference key="parent" ref="694149608"/>
</object>
@@ -1632,6 +1650,11 @@
<reference key="object" ref="738670835"/>
<reference key="parent" ref="963351320"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">537</int>
<reference key="object" ref="208934156"/>
<reference key="parent" ref="110575045"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -1704,6 +1727,7 @@
<string key="491.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="492.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="534.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1722,13 +1746,24 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">536</int>
<int key="maxID">541</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">AtomApp</string>
<string key="superclassName">NSApplication</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">runSpecs:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">runSpecs:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">runSpecs:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/AtomApp.h</string>
@@ -1775,6 +1810,24 @@
<string key="minorKey">./Classes/NSDocument.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">WebView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">reloadFromOrigin:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">reloadFromOrigin:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">reloadFromOrigin:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/WebView.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>