Bold + italic shortcuts in document-based applications

I read using the first responder as a proxy object and dragging connections from buttons to create useful actions (left, right, etc. alignment). However, by default, the first responder does not contain bold and italic actions. I tried to add these actions by opening my Menu.xib and dragging the menu item (Font> Bold) into the first responder and setting it as the boldIt (custom) function, but overwriting the existing action (Font Manager: Addtrait). Is there a way to somewhat add a bold / italic button on document.xib? It seems like a lot of work for something so common. New for Obj-C

Best, Zack

0
objective-c xcode cocoa macos
source share
1 answer

The xib menu has an object (Bold element) whose tag is 2 and whose action is associated with the -addFontTrait: method for an NSFontManager instance.

You just need to do the same in the xib document. Add NSFontManager object; create your live button; set its tag to 2; and hook its action to -addFontTrait in NSFontManager.

+2
source share

All Articles