Re: Still NSTextView custom insertion point
Re: Still NSTextView custom insertion point
- Subject: Re: Still NSTextView custom insertion point
- From: Greg Herlihy <email@hidden>
- Date: Sat, 18 Mar 2006 23:42:51 -0800
- Thread-topic: Still NSTextView custom insertion point
The implementation of drawInsertionPointInRect should both draw and erase
the insertion point. Currently it draws the insertion point when it's
visible, but does no drawing when it is not (instead it invalidates the
drawing area).
It's unlikely that relying on an update is enough to ensure that the
previously-rendered insertion point will be erased while the user is typing.
So this routine should draw the insertion point in either of its states,
itself.
=Greg
On 3/18/06 4:46 PM, "Thierry Passeron" <email@hidden> wrote:
> Dear fellow cocoa developers,
>
> I'm still stuck with this problem of making a custom insertion point
> in an NSTextView. Of course I can set the TextView to not display any
> insertion point and then implement a timer that will do the job. But
> I'm willing to understand why I can't do it the usual way like this:
>
> @interface CommandTextView : NSTextView {
>
> }
>
> @end
>
> @implementation CommandTextView
>
> - (void)drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color
> turnedOn:(BOOL)flag
> {
> NSRect rectDumb=NSMakeRect(5,5,10,10);
>
> if( flag==YES )
> {
> [self lockFocus];
> [color set];
> NSRectFill(rectDumb);
> [self unlockFocus];
> return;
> }
>
> [self lockFocus];
> [self setNeedsDisplayInRect:rectDumb avoidAdditionalLayout:NO];
> [self unlockFocus];
> }
>
> - (void) updateInsertionPointStateAndRestartTimer: (BOOL)restartFlag {
> NSLog(@"update: flag=%d",restartFlag);
> [super updateInsertionPointStateAndRestartTimer:restartFlag];
> }
>
> @end
>
> It works fine when you don't type any text, but, when you type some
> text in the textview, the I-beam insertion point comes back from
> nowhere ... I can't find where it comes from.
> If you comment the [super updateInsertionPoint....] there won't be any
> insertion point at all in the view. So I'm guessing this method is
> mandatory. But what it does is a mistery to me.
>
> Any of you have successfuly created a custom insertion point in an
> NSTextView ? What do I need to do ?
>
> Thanks in advance,
>
> Best regards,
>
> Thierry
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden