【问题标题】:Location on screen of location in NSTextViewNSTextView 中位置屏幕上的位置
【发布时间】:2010-02-11 10:51:10
【问题描述】:

我想在 NSTextView 中获取一个点的屏幕位置(NSPoint),这应该很简单,但结果总是有点偏离,X 是完美的,但 Y 似乎有所不同。

我尝试了以下代码的一些变体,但无法得到我想要的结果,是 NSClipView 搞砸了吗?

NSPoint p = [[self layoutManager] locationForGlyphAtIndex:r.location];
//NSPoint b= [self convertPoint:p toView:nil];
NSPoint screenlocation = [self convertPointToBase:p];

有什么想法吗?

干杯!

MT

【问题讨论】:

    标签: cocoa layout nstextview glyph


    【解决方案1】:

    根据documentation,字形的位置与其封闭的行片段相关。您应该使用线片段的矩形来调整点。这应该可以解决您看到的变化。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 1970-01-01
      • 1970-01-01
      • 2013-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多