Re: NSTextView's MarkedText
Re: NSTextView's MarkedText
- Subject: Re: NSTextView's MarkedText
- From: Gordon Apple <email@hidden>
- Date: Wed, 24 Jul 2013 16:53:26 -0500
- Thread-topic: NSTextView's MarkedText
That link seems to have fallen victim to the outage.
I have added a background setting for selected text. I suppose I could do
that here, but that would defeat what I am trying to do, which is to be able
to paint the text background (possibly with a Wacom pen) in the same way one
would use a highlighting pen on paper. Because this is intended for an
educational presentation system, I would like to be able to do this during
the presentation, then later reset for another class session. Thus the
custom attributes, which can all be easily removed with a single button
click. The active highlighting works (even the iBeam cursor with color
patch), but I need the mouseUp (selection ended) to set the custom
background, remove the custom selection highlighting, revert the cursor,
etc. The switching from selection highlighting to custom background
attribute color completes the illusion.
On 7/24/13 3:46 PM, "Kyle Sluder" <email@hidden> wrote:
> On Wed, Jul 24, 2013, at 12:47 PM, Gordon Apple wrote:
>> > I have now added my own custom attribute, similar to markedText, and it
>> > seems to work as intended. However, I have run into a new problem. I
>> > need
>> > to know when selection if finished, but for some reason, my subclass of
>> > NSTextView can not intercept mouseUp.
>
> NSTextView runs its own tracking loop. See "Handling Mouse Dragging
> Operations":
> https://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/EventO
> verview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/10000
> 060i-CH6-SW1
>
> The plan was at that point to
>> > change
>> > my custom background attribute, deselect the text (actually, set insert
>> > point to end of selection), and clear my custom highlighting. Why canĀ¹t
>> > I
>> > get a mouseUp?
>
> An alternative would be to override -mouseDown: to look something like
> this:
>
> - (void)mouseDown:(NSEvent *)theEvent {
> [super mouseDown:theEvent];
> [self _applyHighlightToSelection];
> }
>
> But have you considered making your highlight feature an actual
> _command_ (like Bold, Italic) instead of a pseudo-selection mechanism?
>
> --Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden