Re: Cursor above siblings
Re: Cursor above siblings
- Subject: Re: Cursor above siblings
- From: Uli Kusterer <email@hidden>
- Date: Sat, 10 Jan 2015 16:54:14 +0100
On 10 Jan 2015, at 16:18, ecir hana <email@hidden> wrote:
> thanks a lot for the reply!
>
> I tried to override "mouseMoved:", "addCursorRect:cursor:",
> "cursorUpdate:", "resetCursorRects", "mouseEntered:" without calling
> "super", but the I-beam cursor is still set when it is being moved over
> NSTextView.
I also tried updateTrackingAreas, for what it’s worth. Though it says you should call super, and remove areas. Maybe that’s worth a try, trying to simulate a super call to NSView instead of the actual super.
> Cursor-update events are a special kind of mouse-tracking event that the
>> Application Kit handles automatically. When the mouse pointer enters a
>> cursor rectangle, the Application Kit displays a cursor image appropriate
>> to the type of view under the rectangle; for example, when a mouse pointer
>> enters a text view, an I-beam cursor is displayed.
>
> One can read the "handles automatically" above as "no easy way to override”.
I think you’re reading that into the documentation. In most views, cursor-setting is pretty much predictable, and I think text views are mainly meant as an example here, and aren’t that special.
> However, I'm not sure I understood your last advice: what "subview" do you
> mean? Both the button (or the view holding the button) and the textview are
> siblings. If I make the button a subview of the textarea it wont show up at
> all..?
You’ll need some way to decide which views to exclude from the text view’s cursor region. The least surprising approach to me seems to be to require the views to be subviews of the NSTextView and then just iterate over them. That said, I haven’t triedit. Subviews are implemented at the NSView level, so I’d expect it to just work (I’ve definitely managed to add subviews to an NSImageView and they drew just fine, even though IB wouldn’t let you embed subviews in one).
> In any case, I will try to look into this further so if anyone has an idea
> about this, please let me know.
I did the same, and one thing that looks like it turns off the cursor is overriding resetCursorRects and updateTrackingAreas to do nothing, and doing
-(void) viewDidMoveToWindow
{
[super viewDidMoveToWindow];
[self.enclosingScrollView setDocumentCursor: nil];
[self.enclosingScrollView updateTrackingAreas];
[self.enclosingScrollView resetCursorRects];
}
That turns off the text view’s cursor, it seems. Maybe there is a simpler way, but if you now implement your own cursor-setting code in your text view that leaves gaps for your buttons, it might solve your problem. It works in the app I just tried it in, but that does a lot of other cursor setting, so it’s not impossible there’s some other code that’s required.
Please let the list know whether this works for you or what conclusion/solution you arrive at, I’d be curious.
Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de
_______________________________________________
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