| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ui/base/cocoa/controls/hyperlink_text_view.h" | 5 #import "ui/base/cocoa/controls/hyperlink_text_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "ui/base/cocoa/nsview_additions.h" | 9 #include "ui/base/cocoa/nsview_additions.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Never draw the insertion point (otherwise, it shows up without any user | 49 // Never draw the insertion point (otherwise, it shows up without any user |
| 50 // action if full keyboard accessibility is enabled). | 50 // action if full keyboard accessibility is enabled). |
| 51 - (BOOL)shouldDrawInsertionPoint { | 51 - (BOOL)shouldDrawInsertionPoint { |
| 52 return NO; | 52 return NO; |
| 53 } | 53 } |
| 54 | 54 |
| 55 - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange | 55 - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange |
| 56 granularity:(NSSelectionGranularity)granularity { | 56 granularity:(NSSelectionGranularity)granularity { |
| 57 // Do not allow selections. | 57 // Return a range of length 0 to prevent text selection. Note that the start |
| 58 return NSMakeRange(0, 0); | 58 // of the range (the first argument) is treated as the position of the |
| 59 // subsequent click so it must not be 0. If it is, links that begin at a |
| 60 // non-zero position in the text will not function correctly when they are |
| 61 // clicked in such a way as to look like a possible text selection. |
| 62 return NSMakeRange(proposedSelRange.location, 0); |
| 59 } | 63 } |
| 60 | 64 |
| 61 // Convince NSTextView to not show an I-Beam cursor when the cursor is over the | 65 // Convince NSTextView to not show an I-Beam cursor when the cursor is over the |
| 62 // text view but not over actual text. | 66 // text view but not over actual text. |
| 63 // | 67 // |
| 64 // http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg10791.html | 68 // http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg10791.html |
| 65 // "NSTextView sets the cursor over itself dynamically, based on considerations | 69 // "NSTextView sets the cursor over itself dynamically, based on considerations |
| 66 // including the text under the cursor. It does so in -mouseEntered:, | 70 // including the text under the cursor. It does so in -mouseEntered:, |
| 67 // -mouseMoved:, and -cursorUpdate:, so those would be points to consider | 71 // -mouseMoved:, and -cursorUpdate:, so those would be points to consider |
| 68 // overriding." | 72 // overriding." |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 }; | 170 }; |
| 167 | 171 |
| 168 [[self textStorage] addAttributes:attributes range:range]; | 172 [[self textStorage] addAttributes:attributes range:range]; |
| 169 } | 173 } |
| 170 | 174 |
| 171 - (void)setRefusesFirstResponder:(BOOL)refusesFirstResponder { | 175 - (void)setRefusesFirstResponder:(BOOL)refusesFirstResponder { |
| 172 refusesFirstResponder_ = refusesFirstResponder; | 176 refusesFirstResponder_ = refusesFirstResponder; |
| 173 } | 177 } |
| 174 | 178 |
| 175 @end | 179 @end |
| OLD | NEW |