-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextFieldCell.rb
60 lines (52 loc) · 1.59 KB
/
TextFieldCell.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class TextFieldCell < NSTextFieldCell
def trackMouse(event, inRect:rect, ofView:view, untilMouseUp:untilMouseUp)
#frame = view.frameOfCellAtColumn(1, row:view.selectedRow)
#view.editColumn 1, row:view.selectedRow, withEvent:nil, select:false
#NSApplication.sharedApplication.sendEvent event
true
end
def setUpFieldEditorAttributes(text)
super
text.delegate = self
text.setSelectable false
text.instance_eval do
def shouldDrawInsertionPoint
false
end
def clickedOnLink(link, atIndex:index)
string = link.absoluteString
return super if string[0..3] == "http"
query = string.gsub '@', 'from:'
window.delegate.addFeed query
end
end
text
end
def textView(text, shouldChangeTextInRange:range, replacementString:replacement)
false
end
def drawingRect(rect)
rect.size.width -= 20
rect.origin.x += 10
textSize = cellSizeForBounds rect
heightDelta = rect.size.height - textSize.height
if heightDelta > 0
rect.size.height -= heightDelta
rect.origin.y += heightDelta / 2
end
rect
end
def drawingRectForBounds(bounds)
rect = super
drawingRect(rect)
end
def selectWithFrame(frame, inView:view, editor:editor, delegate:delegate, start:start, length:length)
rect = drawingRectForBounds frame
super rect, view, editor, delegate, start, length
end
def editWithFrame(frame, inView:view, editor:editor, delegate:delegate, event:event)
rect = drawingRectForBounds frame
rect.origin.y -= 1
super rect, view, editor, delegate, event
end
end