• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: region for window draggging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: region for window draggging


  • Subject: Re: region for window draggging
  • From: Todd Yandell <email@hidden>
  • Date: Sat, 27 May 2006 12:18:01 -0500


On May 27, 2006, at 11:31 AM, Brett George wrote:

Is there a way to define which region of a window supports dragging? Currently, its only the top part of my window that allows it and i'd like to extend this region. I've read of ways to achieve this with a kEventControlGetPartRegion handler, but i'm wondering if there is a way to do it in in Cocoa?

You should subclass the view under the area that you want to enable dragging on, and implement the mouseDown: and mouseDragged: methods, then use those to move the view's window. For example, if you have a status bar like Xcode, and you want the user to be able to drag the window by the status bar, you would subclass that view, then write some code like this:


@implementation StatusBarView

- (void)mouseDown:(NSEvent *)mouseEvent
{
	// mouseStart should be an NSPoint instance variable.
	mouseStart = [mouseEvent locationInWindow];
}

- (void)mouseDragged:(NSEvent *)mouseEvent
{
	NSPoint mousePoint = [mouseEvent locationInWindow];
	NSPoint dragDistance = NSMakePoint(mousePoint.x - mouseStart.x,
		mousePoint.y - mouseStart.y);

	NSPoint frameOrigin = [[self window] frame].origin;
	frameOrigin.x = frameOrigin.x + dragDistance.x;
	frameOrigin.y = frameOrigin.y + dragDistance.y;

	[[self window] setFrameOrigin:frameOrigin];
}

@end

Todd
_______________________________________________
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


  • Follow-Ups:
    • Re: region for window draggging
      • From: "Michael Ash" <email@hidden>
References: 
 >region for window draggging (From: Brett George <email@hidden>)

  • Prev by Date: how do I check the defaults for an object?
  • Next by Date: Re: how do I check the defaults for an object?
  • Previous by thread: region for window draggging
  • Next by thread: Re: region for window draggging
  • Index(es):
    • Date
    • Thread