Search Results

Search found 2 results on 1 pages for 'forchita'.

Page 1/1 | 1 

  • Update NSView in function of events

    - by Forchita
    Hi everyone! I have a main view (subclass of NSView) and as i'm new to cocoa, i'd like to know how to update the view in function of events. I know there are many methods that take events such as -(void)mouseMoved:(NSEvent*)event or - (void)mouseClicked:(NSEvent*)event My algorithm to determine what to do is ready. I want to know where I should update the main view: is it in the -(void)mouseMoved:(NSEvent*)event or in the - (void)drawRect:(NSRect)dirtyRect. And if it is in drawRect, then how should i pass the information to it? Thanks in advance!

    Read the article

  • Draw text with in a rect with given width

    - by Forchita
    I'm trying to draw text on NSView subclass. I'm using an NSTextStorage, an NSLayoutManager, and an NSTextContainer. I followed Apple's doc and here's the method I use to calculate the necessary height for each text: NSSize newSize= NSMakeSize(width, 0.0); NSLayoutManager* layoutManager= [[textStorage layoutManagers] objectAtIndex:0]; NSTextContainer* textContainer= [[layoutManager textContainers] objectAtIndex:0]; [textContainer setContainerSize:newSize]; [textStorage addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, [textStorage length])]; [textContainer setLineFragmentPadding:0.0]; [layoutManager glyphRangeForTextContainer:textContainer]; return [layoutManager usedRectForTextContainer:textContainer].size.height; The only problem is that I don't know how to draw in an NSRect with the layout manager. Can you help me please? Thanks in advance!

    Read the article

1