-
- let string = "\(Int(mouseLocation.x)), \(Int(mouseLocation.y))" as NSString
- let size = string.size(withAttributes: textAttributes)
- let rect = NSRect(x: mouseLocation.x + offset.x, y: mouseLocation.y + offset.y, width: size.width + 2 * padding.x, height: size.height + 2 * padding.y)
- let textRect = NSRect(x: mouseLocation.x + offset.x + padding.x, y: mouseLocation.y + offset.y + padding.y, width: size.width, height: size.height)
+ let offset = NSPoint(x: 10, y: 10)
+ let padding = NSPoint(x: 5, y: 2)
+ let size = text.size(withAttributes: textAttributes)
+ var rect = NSRect(x: location.x + offset.x, y: location.y + offset.y, width: size.width + 2 * padding.x, height: size.height + 2 * padding.y)
+ var textRect = NSRect(x: location.x + offset.x + padding.x, y: location.y + offset.y + padding.y, width: size.width, height: size.height)
+
+ if (isBottomRight) {
+ rect = rect.offsetBy(dx: -size.width - 2 * offset.x, dy: 0)
+ textRect = textRect.offsetBy(dx: -size.width - 2 * offset.x, dy: 0)
+ }