[英]NSTextview: How do I get the glyph rect of the insertion point ? Custom TextView?
我似乎無法找到有關如何獲取插入點的矩形的任何文檔。 我正在嘗試在文本插入符/插入點的正下方顯示一個視圖(如自動完成)
我正在考慮制作一個自定義的textview,但如果我可以避免它,那在我的情況下是理想的。 謝謝!
- (NSRect)rectForActiveRange {
NSLayoutManager *l = [self layoutManager];
NSRange range = [l glyphRangeForCharacterRange:self.activeRange actualCharacterRange:nil];
NSRect rect = [l boundingRectForGlyphRange:range inTextContainer:[self textContainer]];
rect = NSOffsetRect(rect, self.textContainerOrigin.x, self.textContainerOrigin.y);
return rect;
}
activeRange == selectedRange WHICH是選擇范圍或者如果從您鍵入的右側選擇一個長度為0的范圍
另見: http : //www.cocoabuilder.com/archive/cocoa/158706-how-to-find-the-insertion-point-of-nstextview.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.