⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dragfromwell.m

📁 处理WORD文档的
💻 M
字号:
//// DragFromWell.m//// Andrew C. Stone and Stone Design Corp//#import "DRController.h"#import "NSFileManager-Extensions.h"#import "DragFromWell.h"@implementation DragFromWell// these two methods let us drag away without ordering the window front first:- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent {return YES;}- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent{        return YES; 	// see NSView.rtfd for full explanation}- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag{        if (flag) return NSDragOperationCopy;        return NSDragOperationCopy|NSDragOperationGeneric|NSDragOperationLink;}- (BOOL)copyDataTo:pboard{        if (path != nil) {                [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:self];                [pboard setPropertyList:[NSArray arrayWithObject:path] forType:NSFilenamesPboardType];                return YES;        } else return NO;}- (void)setFile:(NSString *)aPath{        [path autorelease];                if (!aPath || [aPath isEqualToString:@""] || ![[NSFileManager defaultManager] fileExistsAtPath:aPath]) {                path = nil;                [self setImage:nil];        } else {                path = [aPath copy];                [self setImage:[[NSWorkspace sharedWorkspace] iconForFile:path]];        }       [self display];}- (void)revealInFinder:(id)sender {	BOOL isDir;	if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]) {            if (isDir)                [[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:path];            else                [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:nil];	}}- (void)mouseDown:(NSEvent *)e{    if (NOT_NULL(path)) {        NSPoint location;        NSSize size;        NSPasteboard *pb = [NSPasteboard pasteboardWithName:(NSString *) NSDragPboard];         NSTimeInterval endTime, startTime = [e timestamp];       if ([e clickCount] > 1) {            [[NSWorkspace sharedWorkspace] openFile:path];	    return;        }        if ([self copyDataTo:pb]) {                size = [[self image] size];                location.x = ([self bounds].size.width - size.width)/2;                location.y = ([self bounds].size.height - size.height)/2;                [self dragImage:[self image] at:location offset:NSZeroSize event:(NSEvent *)e pasteboard:pb source:self slideBack:YES];        }        // if they do drag, we won't do this:        endTime = [[[self window] currentEvent] timestamp];        if (endTime - startTime < .40)            [self performSelector:@selector(revealInFinder:) withObject:nil afterDelay:0.5];        } else [[NSApp delegate] showLogAction:self];}// override drag stuff...- (void)awakeFromNib{    [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];}- (unsigned int) draggingEntered:sender{    return [[self window] draggingEntered:sender];}- (unsigned int) draggingUpdated:sender{    return [[self window] draggingUpdated:sender];}- (BOOL) prepareForDragOperation:sender{        return [[self window] prepareForDragOperation:sender];}- (BOOL) performDragOperation:(id <NSDraggingInfo>)sender{    return [[self window] performDragOperation:sender];}- (void)concludeDragOperation:(id <NSDraggingInfo>)sender {    [[self window] concludeDragOperation:sender];}@end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -