tags:

views:

110

answers:

3

Hi, How can i change a normal font to bold font, Here the text should be selected and say by clicking the button(Bold) button. the selected text should become bold.

A: 

The Cocoa text system already provides a wide array of subsystems for modifying attributed strings and text. You should probably look into using NSTextView before you go rolling your own systems.

However: You might want to look into the NSAttributedString API. You should find it enlightening.

Williham Totland
i can write text on text view. instead of using the format menu how can i make it bold when clicking a button while selecting the text on the text view.
iSight
+1  A: 

Did you look at the "Format" menu in your main menu? There's one called "Bold". You should look at the method that is hooked to that menu item. It's probably some method that's part of "First Responder". If so then hook your button up to "First Responder" and then select that method for the button.

regulus6633
Thanks it did work. But, bold menu hook to font manager not to first responder. just create a button and set the tag as 2, then hook the button to font manager and select addFontTrait: action.
iSight
A: 

bold menu hook to font manager not to first responder. just create a button and set the tag as 2, then hook the button to font manager and select addFontTrait: action.

iSight