Re: Snapping windows while moving
Re: Snapping windows while moving
- Subject: Re: Snapping windows while moving
- From: Steve Mills <email@hidden>
- Date: Sat, 23 Mar 2013 12:00:49 -0500
On Mar 23, 2013, at 02:41:21, Ken Thomases <email@hidden>
wrote:
> Meaning you've overridden -isMovable? Or did you call -setMovable: with NO? I think you have to do the latter because that configures the Window Server's metadata about the window. It might also configure the theme frame views (the framework-private views that make up the title bar, etc.) to behave differently. So, basically, I think "movability" is a value that you have to set rather than something the frameworks and Window Server get by querying -isMovable.
I tried it both ways with the same results.
> I just did a test and confirm what you've described. Then I rechecked the documentation of -isMovable and see that it says you have to handle the mouse down, drag, and up events inside of -sendEvent:. Of course, it confuses matters by referring to those events by their responder method names, when it should have said "Applications may choose to enable application-controlled window dragging after disabling user-initiating dragging by handling the NSLeftMouseDown/NSLeftMouseDragged/NSLeftMouseUp sequence in sendEvent: in an NSWindow subclass."
>
> I tested that approach and it works, of course. -sendEvent: is what would dispatch those events to the theme frame views, but if you handle them directly there, instead, they won't get dispatched that way. You have to be careful to still dispatch clicks inside the title bar's various widgets, or the user won't be able to, for example, close the window by clicking on its close button.
>
> Here's an example which works. It allows moving the window by its background (simply because it doesn't bother checking if the click is in the content view) and I haven't tested if it interferes with clicks in the actual title area (like pulling down the menu for a document), but it probably does.
Amazing bit of sleuthing, Ken! Yeah, I read the mouseDown:/mouseDragged:/mouseUp: part of the docs and chose to ignore the sendEvent: part after that. Thanks so much for the sample code. It's hard to believe this was this hard to figure out and implement, when it's so easily doable under Carbon Events. Bad Apple. No biscuit. And a swat on the nose for not getting the docs right.
--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157
_______________________________________________
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