Re: Detecting textView alignment changes
Re: Detecting textView alignment changes
- Subject: Re: Detecting textView alignment changes
- From: Matt Ball <email@hidden>
- Date: Sat, 1 May 2004 17:48:40 -0400
Nevermind. I figured it out. For anyone who's interested, I implemented
the following in the TextView's delegate:
- (void)textViewDidChangeTypingAttributes:(NSNotification
*)aNotification
{
NSDictionary* dict = [textView typingAttributes];
NSMutableParagraphStyle* alignmentStyle = [dict
objectForKey:NSParagraphStyleAttributeName];
if([alignmentStyle alignment] == NSLeftTextAlignment)
{
[alignmentSegmentedControl setSelectedSegment:0];
}
else if([alignmentStyle alignment] == NSCenterTextAlignment)
{
[alignmentSegmentedControl setSelectedSegment:1];
}
else if([alignmentStyle alignment] == NSJustifiedTextAlignment)
{
[alignmentSegmentedControl setSelectedSegment:2];
}
else if([alignmentStyle alignment] == NSRightTextAlignment)
{
[alignmentSegmentedControl setSelectedSegment:3];
}
}
-- Matt Ball
On May 1, 2004, at 3:27 PM, Matt Ball wrote:
>
I have an NSSegmentedControl in the toolbar of my app, which, when
>
pressed, changes the alignment of a textView. I need to know when a
>
user changes the textView's alignment using the menu so that I can
>
update the segmentedControl to reflect the new alignment. I also need
>
to know when the alignment has changed within a document (ie: on line
>
4, it is aligned to the right, but on line 5, it is centered. When the
>
user moves the cursor to line 5, I need to change the SegmentedControl
>
to reflect the new alignment). Is there some sort of NSNotification
>
that will help me accomplish this? Thanks.
>
>
-- Matt Ball
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.