Cocoa osx NSButton displays text when mouse
4 answers
In Interface-Builder, you can set a "hint" for most objects, including the NSButton (Open Inspector, then select the Help topic). However, if you are using NSToolbar, it also has tooltips; you can do it programmatically. Try typing setToolTip in your source, then select an option - double click it for more information. (Option = alternative).
+5
user1985657
source
to share
To programmatically add a custom tooltip in Swift, subclass the appropriate view
var trackingArea: NSTrackingArea!
Add a tracking area to view
let opts: NSTrackingAreaOptions = ([NSTrackingAreaOptions.MouseEnteredAndExited, NSTrackingAreaOptions.ActiveAlways])
trackingArea = NSTrackingArea(rect: bounds, options: opts, owner: self, userInfo: nil)
self.addTrackingArea(trackingArea)
Injected mouse event
override func mouseEntered(theEvent: NSEvent) {
self.tooltip = "Sad face : Select the option for very poor"
}
Or you can make a separate hint for each range of the string: fooobar.com/questions/472241 / ...
+2
source to share