Dragging caret in NSTextView doesn't match result of characterIndexForPoint

后端 未结 1 1598
既然无缘
既然无缘 2021-01-19 16:31

I\'m dragging onto an NSTextView (from a table in another window) and as I drag over the text in the NSTextView a caret is displayed showing the insertion point. There appea

1条回答
  •  时光说笑
    2021-01-19 16:49

    Ok, the solution is to use characterIndexForInsertionAtPoint instead of characterIndexForPoint. Thusly,

    NSPoint mouseLocation = [sender draggingLocation];
    NSUInteger dropLocation = [self characterIndexForInsertionAtPoint:[self convertPoint:mouseLocation fromView:nil]];
    

    0 讨论(0)
提交回复
热议问题