source: trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEWebKit.m@ 185

Last change on this file since 185 was 183, checked in by Nicholas Riley, 19 years ago

ICeCoffEE 1.4.2b1

VERSION, ui.plist, Info*.plist, InfoPlist.strings: Updated for 1.4.2b1.

APEMain.m: Removed PBX support.

ICeCoffEE.[hm]: Don't ICCF_OSErr(C)Assert if we get userCanceledErr:
part of fixing extraneous exception when not selecting anything from
the helper app menu. ICCF_KeyboardAction() and
ICCF_LaunchURLFromTextView() now take an event parameter - since we
have stuff on a timer now, means we get the key modifier state at
mousedown time, rather than some arbitrary time later.
ICCF_LaunchURL() returns NO if the user cancelled, so we don't need to
throw an exception to stop the URL blinking. Moved sanitized mouse
down event generation to ICCF_MouseDownEventWithModifierFlags(). Only
update Services menu at app launch on Panther. Use a timer to delay
URL launching in NSTextView on Tiger, so we accommodate
command-multiple clicking for discontiguous selection. Remove that
ugly goto.

ICeCoffEEShared.h: Turn off debugging in preparation for (beta)
release.

ICeCoffEETerminal.m: Update for new ICCF_LaunchURL() return.

ICeCoffEETrigger.[hm]: Singleton timer wrapper for discontiguous
selection compatibility on Tiger. Singleton global is exported for
efficiency since we have to check it on every mouse down.

ICeCoffEEWebKit.m: Removed incorrect comment (what was I thinking?)
Update for new ICCF_LaunchURL() return. Properly highlight before
ICCF_LaunchURL(), especially noticable with menu.

APEInfo.rtfd: More fixes and updates, final for 1.4.2b1.

File size: 3.5 KB
Line 
1//
2// ICeCoffEEWebKit.m
3// ICeCoffEE APE
4//
5// Created by Nicholas Riley on Sun Jan 19 2003.
6// Copyright (c) 2003 Nicholas Riley. All rights reserved.
7//
8
9#import "ICeCoffEEWebKit.h"
10#import <unistd.h>
11
12// from WebCoreBridge.h
13@interface WebCoreBridge : NSObject
14
15- (NSDictionary *)elementAtPoint:(NSPoint)point;
16- (NSString *)selectedString;
17- (NSRect)selectionRect;
18
19- (void)selectNSRange:(NSRange)range;
20- (void)deselectAll;
21
22@end
23
24// from WebKit, private
25@interface WebHTMLView : NSObject
26
27- (WebCoreBridge *)_bridge;
28
29- (NSRange)selectedRange;
30
31@end
32
33@implementation ICeCoffEEWebKit
34
35- (NSMenu *)menuForEvent:(NSEvent *)e;
36{
37 NSMenu *myMenu = [super menuForEvent: e];
38 return ICCF_MenuForEvent(self, myMenu, e);
39}
40
41static NSEvent *downEvent = nil;
42static NSString *selectedString = nil;
43static NSRange selectedRange;
44
45- (void)mouseDown:(NSEvent *)e;
46{
47 [downEvent release]; downEvent = nil;
48 if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) {
49 WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
50 if ([self respondsToSelector: @selector(selectedRange)]) {
51 // save selection: it may be deselected on super mouseDown
52 selectedRange = [(WebHTMLView *)self selectedRange];
53 }
54 [selectedString release]; selectedString = nil;
55 selectedString = [[bridge selectedString] retain];
56 downEvent = [e retain];
57 }
58 [super mouseDown: e];
59}
60
61- (void)mouseUp:(NSEvent *)e;
62{
63 [super mouseUp: e];
64 if (downEvent != nil) {
65 NSPoint downPt = [downEvent locationInWindow];
66 NSPoint upPt = [e locationInWindow];
67 if (abs(downPt.x - upPt.x) > kICHysteresisPixels && abs(downPt.y - upPt.y) > kICHysteresisPixels)
68 return;
69
70 NS_DURING
71 WebCoreBridge *bridge = [(WebHTMLView *)self _bridge];
72 NSPoint viewClickPt = [self convertPoint: downPt fromView: nil];
73 NSDictionary *elementDict = [bridge elementAtPoint: viewClickPt];
74 ICLog(@"elementDict: %@", elementDict);
75 NSAssert([elementDict count] != 0, @"Internal error: Got empty element dictionary from WebHTMLView");
76 if ([elementDict objectForKey: @"WebElementLinkURL"] != nil) {
77 ICLog(@"got a link");
78 NS_VOIDRETURN; // donÕt activate on links
79 }
80 if (selectedString == nil || [selectedString length] == 0) {
81 ICLog(@"no selected string");
82 NS_VOIDRETURN;
83 }
84 ICCF_StartIC();
85 BOOL canSetSelection = [bridge respondsToSelector: @selector(selectNSRange:)];
86 if (canSetSelection) {
87 // may have become deselected in mouseDown
88 [bridge selectNSRange: selectedRange];
89 }
90 if (ICCF_LaunchURL(selectedString, ICCF_KeyboardAction(downEvent)) && ICCF_prefs.textBlinkEnabled && canSetSelection) {
91 int i;
92 NSRect selectionRect = [bridge selectionRect];
93 ICLog(@"selectedRange %@ selectionRect %@ textBlinkCount %d", NSStringFromRange(selectedRange), NSStringFromRect(selectionRect), ICCF_prefs.textBlinkCount);
94 for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) {
95 [bridge deselectAll];
96 [self setNeedsDisplayInRect: selectionRect];
97 [self display];
98 usleep(kICBlinkDelayUsecs);
99 [bridge selectNSRange: selectedRange];
100 [self setNeedsDisplayInRect: selectionRect];
101 [self display];
102 usleep(kICBlinkDelayUsecs);
103 }
104 }
105 NS_HANDLER
106 ICCF_HandleException(localException);
107 NS_ENDHANDLER
108
109 [downEvent release]; downEvent = nil;
110 ICCF_StopIC();
111 }
112}
113
114@end
Note: See TracBrowser for help on using the repository browser.