Skip to content

Commit 6f98a1a

Browse files
More improvements to "popping" code
1 parent a8a6a56 commit 6f98a1a

File tree

8 files changed

+115
-87
lines changed

8 files changed

+115
-87
lines changed

AppController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ void outletObjectAwoke(id sender);
209209
- (NSColor *)foregrndColor;
210210
- (void)updateWordCount:(BOOL)doIt;
211211
- (void)ensurePreviewIsVisible;
212+
- (void)resetModTimers;
212213
- (IBAction)toggleWordCount:(id)sender;
213214
- (IBAction)togglePreview:(id)sender;
214215
- (IBAction)toggleSourceView:(id)sender;

AppController.m

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ - (void)applicationWillResignActive:(NSNotification *)aNotification {
10871087
[notationController synchronizeNoteChanges:nil];
10881088
[cView setInactiveIcon:self];
10891089
[self resetModTimers];
1090+
10901091
}
10911092

10921093
- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
@@ -1303,8 +1304,9 @@ - (void)cacheTypedStringIfNecessary:(NSString*)aString {
13031304

13041305
//from fieldeditor
13051306
- (void)controlTextDidChange:(NSNotification *)aNotification {
1306-
1307+
13071308
if ([aNotification object] == field) {
1309+
[self resetModTimers];
13081310
typedStringIsCached = NO;
13091311
isFilteringFromTyping = YES;
13101312

@@ -1364,6 +1366,7 @@ - (void)controlTextDidChange:(NSNotification *)aNotification {
13641366
}
13651367

13661368
isFilteringFromTyping = NO;
1369+
13671370
} else if ([TagEditer isMultitagging]) { //<--for elasticthreads multitagging
13681371
if (!isAutocompleting&&!wasDeleting) {
13691372
isAutocompleting = YES;
@@ -1404,6 +1407,7 @@ - (void)tableViewSelectionIsChanging:(NSNotification *)aNotification {
14041407
BOOL allowMultipleSelection = NO;
14051408
NSEvent *event = [window currentEvent];
14061409

1410+
[self resetModTimers];
14071411
NSEventType type = [event type];
14081412
//do not allow drag-selections unless a modifier is pressed
14091413
if (type == NSLeftMouseDragged || type == NSLeftMouseDown) {
@@ -1624,6 +1628,7 @@ - (BOOL)displayContentsForNoteAtIndex:(int)noteIndex {
16241628
- (void)textDidChange:(NSNotification *)aNotification {
16251629
id textObject = [aNotification object];
16261630

1631+
//[self resetModTimers];
16271632
if (textObject == textView) {
16281633
[currentNote setContentString:[textView textStorage]];
16291634
[self postTextUpdate];
@@ -2048,6 +2053,8 @@ - (IBAction)fixFileEncoding:(id)sender {
20482053
}
20492054

20502055
- (void)windowDidResignKey:(NSNotification *)notification{
2056+
2057+
[self resetModTimers];
20512058
if ([notification object] == [TagEditer tagPanel]) { //<--this is for ElasticThreads' multitagging window
20522059

20532060
if ([TagEditer isMultitagging]) {
@@ -2063,6 +2070,8 @@ - (void)windowDidResignKey:(NSNotification *)notification{
20632070
}
20642071

20652072
- (void)windowWillClose:(NSNotification *)aNotification {
2073+
2074+
[self resetModTimers];
20662075
if ([prefsController quitWhenClosingWindow]){
20672076
[NSApp terminate:nil];
20682077
}
@@ -2961,61 +2970,30 @@ - (IBAction)toggleWordCount:(id)sender{
29612970

29622971
}
29632972

2964-
29652973
- (void)flagsChanged:(NSEvent *)theEvent{
29662974
// if (ModFlagger>=0) {
2967-
if (([theEvent modifierFlags]&NSAlternateKeyMask)&&(([theEvent keyCode]==58)||([theEvent keyCode]==61))) { //option down&NSKeyDownMask
2968-
if((ModFlagger==0)&&(popped==0)){
2975+
// NSLog(@"flagschanged :>%@<",theEvent);
2976+
if ((ModFlagger==0)&&(popped==0)&&([theEvent modifierFlags]&NSAlternateKeyMask)&&(([theEvent keyCode]==58)||([theEvent keyCode]==61))) { //option down&NSKeyDownMask
29692977
ModFlagger = 1;
29702978
modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:1.2
29712979
target:self
29722980
selector:@selector(updateModifier:)
29732981
userInfo:@"option"
29742982
repeats:NO] retain];
2975-
}else{
2976-
ModFlagger=0;
2977-
}
2978-
}else if (([theEvent modifierFlags]&NSControlKeyMask)&&(([theEvent keyCode]==59)||([theEvent keyCode]==62))) { //control down
2979-
if((ModFlagger==0)&&(popped==0)){
2983+
2984+
}else if ((ModFlagger==0)&&(popped==0)&&([theEvent modifierFlags]&NSControlKeyMask)&&(([theEvent keyCode]==59)||([theEvent keyCode]==62))) { //control down
29802985
ModFlagger = 2;
29812986
modifierTimer = [[NSTimer scheduledTimerWithTimeInterval:1.2
29822987
target:self
29832988
selector:@selector(updateModifier:)
29842989
userInfo:@"control"
29852990
repeats:NO] retain];
2986-
}else{
2987-
ModFlagger=0;
2988-
}
2989-
}else if ([theEvent modifierFlags]==256){
29902991

2991-
ModFlagger = 0;
2992-
if (modifierTimer){
2993-
if ([modifierTimer isValid]) {
2994-
[modifierTimer invalidate];
2995-
}
2996-
modifierTimer = nil;
2997-
[modifierTimer release];
2998-
}
2999-
if (popped>0) {
3000-
3001-
if ((popped==1)&&(([theEvent keyCode]==58)||([theEvent keyCode]==61))) {//option up
3002-
[self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.3];
3003-
3004-
}else if ((popped==2)&&(([theEvent keyCode]==59)||([theEvent keyCode]==62))) { //control up
3005-
[self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.3];
3006-
}
3007-
popped=0;
3008-
3009-
}
30102992
}else {
3011-
ModFlagger = -1;
3012-
if (modifierTimer) {
3013-
if ([modifierTimer isValid]) {
3014-
[modifierTimer invalidate];
3015-
}
3016-
modifierTimer = nil;
3017-
[modifierTimer release];
3018-
}
2993+
[self resetModTimers];
2994+
/* if ([theEvent modifierFlags]==256){
2995+
ModFlagger = 0;
2996+
}*/
30192997
}
30202998
}
30212999

@@ -3036,13 +3014,23 @@ - (void)updateModifier:(NSTimer*)theTimer{
30363014
}
30373015

30383016
- (void)resetModTimers{
3039-
if (popped==1) {
3040-
[self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.1];
3041-
}else if (popped==2) {
3042-
[self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.1];
3043-
}
3044-
popped=0;
3045-
ModFlagger = 0;
3017+
// NSLog(@"resetmods");
3018+
if ((ModFlagger>0)||(popped>0)) {
3019+
ModFlagger = 0;
3020+
if (modifierTimer){
3021+
if ([modifierTimer isValid]) {
3022+
[modifierTimer invalidate];
3023+
}
3024+
modifierTimer = nil;
3025+
[modifierTimer release];
3026+
}
3027+
if (popped==1) {
3028+
[self performSelector:@selector(popWordCount:) withObject:NO afterDelay:0.1];
3029+
}else if (popped==2) {
3030+
[self performSelector:@selector(popPreview:) withObject:NO afterDelay:0.1];
3031+
}
3032+
popped=0;
3033+
}
30463034
}
30473035

30483036

@@ -3187,4 +3175,10 @@ - (void)refreshNotesList
31873175
[notesTableView setNeedsDisplay:YES];
31883176
}
31893177

3178+
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent {
3179+
NSLog(@"perform key AC");
3180+
[[NSApp delegate] resetModTimers];
3181+
return [super performKeyEquivalent:theEvent];
3182+
}
3183+
31903184
@end

BookmarksTable.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
2727
}
2828

2929
- (void)keyDown:(NSEvent*)theEvent {
30-
3130
unichar keyChar = [theEvent firstCharacter];
3231

3332
if (keyChar == NSDeleteCharacter || keyChar == NSDeleteFunctionKey) {

DualField.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ + (BOOL)prefersTrackingUntilMouseUp {
179179
return YES;
180180
}
181181

182+
182183
@end
183184

184185
@implementation DualField
@@ -499,6 +500,8 @@ - (void)drawRect:(NSRect)rect {
499500
}
500501

501502
//elasticwork
503+
504+
502505
- (void)flagsChanged:(NSEvent *)theEvent{
503506
[[NSApp delegate] flagsChanged:theEvent];
504507
}

ETContentView.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ - (void)dealloc
2525
[super dealloc];
2626
}
2727

28+
- (void)keyDown:(NSEvent *)theEvent{
29+
// NSLog(@"keydownCV");
30+
[[NSApp delegate] resetModTimers];
31+
[super keyDown:theEvent];
32+
// [super interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
33+
}
34+
2835
- (void)drawRect:(NSRect)dirtyRect
2936
{
3037
[super drawRect:dirtyRect];

0 commit comments

Comments
 (0)