added url to virtual key

This commit is contained in:
Jeena Paradies 2010-05-01 15:16:51 +02:00
parent 543e4e99eb
commit 457a08ea91
8 changed files with 254 additions and 211 deletions

21
Constants.h Normal file
View file

@ -0,0 +1,21 @@
//
// Constants.h
// Twittia 2
//
// Created by Jeena on 01.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
@interface Constants : NSObject {
}
#define TWEET_MAX_LENGTH 140
+ (NSString *)stringFromVirtualKeyCode:(NSInteger)code;
@end

219
Constants.m Normal file
View file

@ -0,0 +1,219 @@
//
// Constants.m
// Twittia 2
//
// Created by Jeena on 01.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "Constants.h"
@implementation Constants
+ (NSString *)stringFromVirtualKeyCode:(NSInteger)code {
NSString *string;
switch (code) {
case kVK_ANSI_A:
string = @"A";
break;
case kVK_ANSI_S:
string = @"S";
break;
case kVK_ANSI_D:
string = @"D";
break;
case kVK_ANSI_F:
string = @"F";
break;
case kVK_ANSI_H:
string = @"H";
break;
case kVK_ANSI_G:
string = @"G";
break;
case kVK_ANSI_Z:
string = @"Z";
break;
case kVK_ANSI_X:
string = @"X";
break;
case kVK_ANSI_C:
string = @"C";
break;
case kVK_ANSI_V:
string = @"V";
break;
case kVK_ANSI_B:
string = @"B";
break;
case kVK_ANSI_Q:
string = @"Q";
break;
case kVK_ANSI_W:
string = @"W";
break;
case kVK_ANSI_E:
string = @"E";
break;
case kVK_ANSI_R:
string = @"R";
break;
case kVK_ANSI_Y:
string = @"Y";
break;
case kVK_ANSI_T:
string = @"T";
break;
case kVK_ANSI_1:
string = @"1";
break;
case kVK_ANSI_2:
string = @"2";
break;
case kVK_ANSI_3:
string = @"3";
break;
case kVK_ANSI_4:
string = @"4";
break;
case kVK_ANSI_6:
string = @"6";
break;
case kVK_ANSI_5:
string = @"5";
break;
case kVK_ANSI_Equal:
string = @"=";
break;
case kVK_ANSI_9:
string = @"9";
break;
case kVK_ANSI_7:
string = @"7";
break;
case kVK_ANSI_Minus:
string = @"-";
break;
case kVK_ANSI_8:
string = @"8";
break;
case kVK_ANSI_0:
string = @"0";
break;
case kVK_ANSI_RightBracket:
string = @")";
break;
case kVK_ANSI_O:
string = @"0";
break;
case kVK_ANSI_U:
string = @"U";
break;
case kVK_ANSI_LeftBracket:
string = @"(";
break;
case kVK_ANSI_I:
string = @"I";
break;
case kVK_ANSI_P:
string = @"P";
break;
case kVK_ANSI_L:
string = @"L";
break;
case kVK_ANSI_J:
string = @"J";
break;
case kVK_ANSI_Quote:
string = @"\"";
break;
case kVK_ANSI_K:
string = @"K";
break;
case kVK_ANSI_Semicolon:
string = @";";
break;
case kVK_ANSI_Backslash:
string = @"\\";
break;
case kVK_ANSI_Comma:
string = @",";
break;
case kVK_ANSI_Slash:
string = @"/";
break;
case kVK_ANSI_N:
string = @"N";
break;
case kVK_ANSI_M:
string = @"M";
break;
case kVK_ANSI_Period:
string = @".";
break;
case kVK_ANSI_Grave:
string = @"`";
break;
case kVK_ANSI_KeypadDecimal:
string = @".";
break;
case kVK_ANSI_KeypadMultiply:
string = @"*";
break;
case kVK_ANSI_KeypadPlus:
string = @"+";
break;
case kVK_ANSI_KeypadClear:
string = @"";
break;
case kVK_ANSI_KeypadDivide:
string = @"/";
break;
case kVK_ANSI_KeypadEnter:
string = @"⎆";
break;
case kVK_ANSI_KeypadMinus:
string = @"-";
break;
case kVK_ANSI_KeypadEquals:
string = @"=";
break;
case kVK_ANSI_Keypad0:
string = @"0";
break;
case kVK_ANSI_Keypad1:
string = @"1";
break;
case kVK_ANSI_Keypad2:
string = @"2";
break;
case kVK_ANSI_Keypad3:
string = @"3";
break;
case kVK_ANSI_Keypad4:
string = @"4";
break;
case kVK_ANSI_Keypad5:
string = @"5";
break;
case kVK_ANSI_Keypad6:
string = @"6";
break;
case kVK_ANSI_Keypad7:
string = @"7";
break;
case kVK_ANSI_Keypad8:
string = @"8";
break;
case kVK_ANSI_Keypad9:
string = @"9";
break;
default:
break;
}
return string;
}
@end

View file

@ -10,6 +10,7 @@
#import <Webkit/Webkit.h>
#import "ViewDelegate.h"
#import <Carbon/Carbon.h>
#import "Constants.h"
@interface Controller : NSObject {
@ -36,6 +37,5 @@
- (void)unreadMentions:(NSInteger)count;
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
+ (NSString *)stringFromVirtualKeyCode:(NSInteger)code;
@end

View file

@ -37,8 +37,8 @@
- (void)initHotKeys {
NSInteger newTweetKey = kVK_ANSI_T; // HIToolbox/Events.h
NSInteger newTweetModifierKey = controlKey + cmdKey + optionKey; // controlKey 4096, cmdKey 256, optionKey 2048
NSInteger newTweetKey = kVK_ANSI_T; // http://boredzo.org/blog/archives/2007-05-22/virtual-key-codes
NSInteger newTweetModifierKey = controlKey + cmdKey + optionKey; // cmdKey 256, shitfKey 512, optionKey 2048, controlKey 4096
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger defaultsNewTweetKey = (NSInteger)[defaults integerForKey:@"newTweetKey"];
@ -61,7 +61,7 @@
if (newTweetModifierKey & controlKey) cocoaModifiers = cocoaModifiers | NSControlKeyMask;
if (newTweetModifierKey & cmdKey) cocoaModifiers = cocoaModifiers | NSCommandKeyMask;
NSLog(@"%i", NSShiftKeyMask);
NSLog(@"%i", shiftKey);
NSInteger theNumber = cocoaModifiers;
NSMutableString *str = [NSMutableString string];
NSInteger numberCopy = theNumber; // so you won't change your original value
@ -75,7 +75,7 @@
NSLog(@"%c", kVK_ANSI_T);
[globalHotkeyMenuItem setKeyEquivalent:[Controller stringFromVirtualKeyCode:newTweetKey]];
[globalHotkeyMenuItem setKeyEquivalent:[Constants stringFromVirtualKeyCode:newTweetKey]];
[globalHotkeyMenuItem setKeyEquivalentModifierMask:cocoaModifiers];
@ -181,211 +181,6 @@
}
}
+ (NSString *)stringFromVirtualKeyCode:(NSInteger)code {
NSString *string;
switch (code) {
case kVK_ANSI_A:
string = @"A";
break;
case kVK_ANSI_S:
string = @"S";
break;
case kVK_ANSI_D:
string = @"D";
break;
case kVK_ANSI_F:
string = @"F";
break;
case kVK_ANSI_H:
string = @"H";
break;
case kVK_ANSI_G:
string = @"G";
break;
case kVK_ANSI_Z:
string = @"Z";
break;
case kVK_ANSI_X:
string = @"X";
break;
case kVK_ANSI_C:
string = @"C";
break;
case kVK_ANSI_V:
string = @"V";
break;
case kVK_ANSI_B:
string = @"B";
break;
case kVK_ANSI_Q:
string = @"Q";
break;
case kVK_ANSI_W:
string = @"W";
break;
case kVK_ANSI_E:
string = @"E";
break;
case kVK_ANSI_R:
string = @"R";
break;
case kVK_ANSI_Y:
string = @"Y";
break;
case kVK_ANSI_T:
string = @"T";
break;
case kVK_ANSI_1:
string = @"1";
break;
case kVK_ANSI_2:
string = @"2";
break;
case kVK_ANSI_3:
string = @"3";
break;
case kVK_ANSI_4:
string = @"4";
break;
case kVK_ANSI_6:
string = @"6";
break;
case kVK_ANSI_5:
string = @"5";
break;
case kVK_ANSI_Equal:
string = @"=";
break;
case kVK_ANSI_9:
string = @"9";
break;
case kVK_ANSI_7:
string = @"7";
break;
case kVK_ANSI_Minus:
string = @"-";
break;
case kVK_ANSI_8:
string = @"8";
break;
case kVK_ANSI_0:
string = @"0";
break;
case kVK_ANSI_RightBracket:
string = @")";
break;
case kVK_ANSI_O:
string = @"0";
break;
case kVK_ANSI_U:
string = @"U";
break;
case kVK_ANSI_LeftBracket:
string = @"(";
break;
case kVK_ANSI_I:
string = @"I";
break;
case kVK_ANSI_P:
string = @"P";
break;
case kVK_ANSI_L:
string = @"L";
break;
case kVK_ANSI_J:
string = @"J";
break;
case kVK_ANSI_Quote:
string = @"\"";
break;
case kVK_ANSI_K:
string = @"K";
break;
case kVK_ANSI_Semicolon:
string = @";";
break;
case kVK_ANSI_Backslash:
string = @"\\";
break;
case kVK_ANSI_Comma:
string = @",";
break;
case kVK_ANSI_Slash:
string = @"/";
break;
case kVK_ANSI_N:
string = @"N";
break;
case kVK_ANSI_M:
string = @"M";
break;
case kVK_ANSI_Period:
string = @".";
break;
case kVK_ANSI_Grave:
string = @"`";
break;
case kVK_ANSI_KeypadDecimal:
string = @".";
break;
case kVK_ANSI_KeypadMultiply:
string = @"*";
break;
case kVK_ANSI_KeypadPlus:
string = @"+";
break;
case kVK_ANSI_KeypadClear:
string = @"";
break;
case kVK_ANSI_KeypadDivide:
string = @"/";
break;
case kVK_ANSI_KeypadEnter:
string = @"⎆";
break;
case kVK_ANSI_KeypadMinus:
string = @"-";
break;
case kVK_ANSI_KeypadEquals:
string = @"=";
break;
case kVK_ANSI_Keypad0:
string = @"0";
break;
case kVK_ANSI_Keypad1:
string = @"1";
break;
case kVK_ANSI_Keypad2:
string = @"2";
break;
case kVK_ANSI_Keypad3:
string = @"3";
break;
case kVK_ANSI_Keypad4:
string = @"4";
break;
case kVK_ANSI_Keypad5:
string = @"5";
break;
case kVK_ANSI_Keypad6:
string = @"6";
break;
case kVK_ANSI_Keypad7:
string = @"7";
break;
case kVK_ANSI_Keypad8:
string = @"8";
break;
case kVK_ANSI_Keypad9:
string = @"9";
break;
default:
break;
}
return string;
}
/* CARBON */

View file

@ -7,12 +7,12 @@
//
#import "MyDocument.h"
#import "Constants.h"
@implementation MyDocument
@synthesize textField, counter;
#define TWEET_MAX_LENGTH 140
- (id)init
{

View file

@ -13,6 +13,7 @@
<body>
<h1>Twittia 2.1.1</h1>
<p>Added possibility to change hot key in defaults.</>
<p>Added a notice to the timeline window how many unread mentions there are.</p>
<p>Changed the plugin API to support more functionality.</p>

View file

@ -15,6 +15,7 @@
1F4674091180F7F3006CC37C /* jQuery-Plugins.js in Resources */ = {isa = PBXBuildFile; fileRef = 1F4673E41180F590006CC37C /* jQuery-Plugins.js */; };
1F705EA6117889FA00C85707 /* sprite-icons.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F705EA5117889FA00C85707 /* sprite-icons.png */; };
1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F70619E1178FBB300C85707 /* Carbon.framework */; };
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F77DB46118C5F1C007C7F1E /* Constants.m */; };
1FE2FC93117A818D000504B0 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FE2FC92117A818D000504B0 /* Sparkle.framework */; };
1FE2FCA4117A83B1000504B0 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1FE2FC92117A818D000504B0 /* Sparkle.framework */; };
1FFA36CD1177D861006C8562 /* even-bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FFA36C81177D861006C8562 /* even-bg.png */; };
@ -59,6 +60,8 @@
1F4673E61180F654006CC37C /* TwittiaCore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TwittiaCore.js; sourceTree = "<group>"; };
1F705EA5117889FA00C85707 /* sprite-icons.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "sprite-icons.png"; sourceTree = "<group>"; };
1F70619E1178FBB300C85707 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
1F77DB45118C5F1C007C7F1E /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = "<group>"; };
1F77DB46118C5F1C007C7F1E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = "<group>"; };
1FE2FC92117A818D000504B0 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
1FE2FCA6117A8952000504B0 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
1FFA36C81177D861006C8562 /* even-bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "even-bg.png"; sourceTree = "<group>"; };
@ -163,6 +166,8 @@
1FFA36D51177D879006C8562 /* ViewDelegate.m */,
2A37F4AEFDCFA73011CA2CEA /* MyDocument.h */,
2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */,
1F77DB45118C5F1C007C7F1E /* Constants.h */,
1F77DB46118C5F1C007C7F1E /* Constants.m */,
);
name = Classes;
sourceTree = "<group>";
@ -272,6 +277,7 @@
8D15AC320486D014006FF6A4 /* main.m in Sources */,
1FFA36D71177D879006C8562 /* Controller.m in Sources */,
1FFA36D81177D879006C8562 /* ViewDelegate.m in Sources */,
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View file

@ -8,6 +8,7 @@
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#import "Constants.h"
@interface ViewDelegate : NSObject {
WebView *timelineView;