ctlIME // Tweak tooltip axis during vertical typing.
This commit is contained in:
parent
e3c832011e
commit
34fa183148
|
@ -26,7 +26,16 @@ extension ctlInputMethod {
|
|||
)
|
||||
cursor -= 1
|
||||
}
|
||||
ctlInputMethod.tooltipController.show(tooltip: tooltip, at: lineHeightRect.origin)
|
||||
var finalOrigin: NSPoint = lineHeightRect.origin
|
||||
if isVerticalTyping {
|
||||
finalOrigin = NSPoint(
|
||||
x: lineHeightRect.origin.x + lineHeightRect.size.width + 4.0, y: lineHeightRect.origin.y - 4.0
|
||||
)
|
||||
ctlInputMethod.tooltipController.direction = .vertical
|
||||
} else {
|
||||
ctlInputMethod.tooltipController.direction = .horizontal
|
||||
}
|
||||
ctlInputMethod.tooltipController.show(tooltip: tooltip, at: finalOrigin)
|
||||
}
|
||||
|
||||
func show(candidateWindowWith state: InputStateProtocol) {
|
||||
|
|
|
@ -20,6 +20,11 @@ public class TooltipController: NSWindowController {
|
|||
case prompt
|
||||
}
|
||||
|
||||
public enum displayDirection {
|
||||
case horizontal
|
||||
case vertical
|
||||
}
|
||||
|
||||
private var backgroundColor = NSColor.windowBackgroundColor
|
||||
private var textColor = NSColor.windowBackgroundColor
|
||||
private var messageTextField: NSTextField
|
||||
|
@ -30,6 +35,8 @@ public class TooltipController: NSWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
public var direction: displayDirection = .horizontal
|
||||
|
||||
public init() {
|
||||
let contentRect = NSRect(x: 128.0, y: 128.0, width: 300.0, height: 20.0)
|
||||
let styleMask: NSWindow.StyleMask = [.borderless, .nonactivatingPanel]
|
||||
|
@ -157,6 +164,7 @@ public class TooltipController: NSWindowController {
|
|||
var rect = attrString.boundingRect(
|
||||
with: NSSize(width: 1600.0, height: 1600.0), options: .usesLineFragmentOrigin
|
||||
)
|
||||
|
||||
rect.size.width += 10
|
||||
messageTextField.frame = rect
|
||||
window?.setFrame(rect, display: true)
|
||||
|
|
Loading…
Reference in New Issue