• 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: create custom control same as multiple monitor control that manages monitors windows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: create custom control same as multiple monitor control that manages monitors windows


  • Subject: Re: create custom control same as multiple monitor control that manages monitors windows
  • From: Paul Bruneau <email@hidden>
  • Date: Mon, 12 Jan 2009 10:48:44 -0500

On Jan 12, 2009, at 12:19 AM, Gami Ravi wrote:

Hi All,

I want to create custom control that looks like a multiple monitor control that manages monitors on Mac. The custom control should allow the rectangle dragging and resizing same way we are moving monitor rectangle can be moved. If there are two rectangles then custom control should not allow overlapping of two rectangles?

What is the efficient way to design such control?

Any help would be appreciated.

The way I did a similar thing (and I think this is the standard way) was to create a custom NSView subclass to draw the control.


Keep track of the location and size of your monitor rectangles somewhere. Maybe you have an object for each monitor? Or maybe you just have instance variables in a controller class.

Override the -drawRect method of NSView to draw your rectangles, etc.

Override the -mouseDown method that NSView inherits from NSResponder to see if the user clicked on one of the rectangles.

Override the -mouseDragged method that NSView inherits from NSResponder to see where the user is dragging the rectangle. Only allow the user to drag it where it is possible to drag it (according to your rules)

Override the -mouseUp method to see where the user ended up leaving it.


This view programming guide should tell you everything you need to know about drawing and responding to user events in custom views:


http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/chapter_1_section_1.html

Good luck!
_______________________________________________

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


  • Follow-Ups:
    • Re: create custom control same as multiple monitor control that manages monitors windows
      • From: "I. Savant" <email@hidden>
References: 
 >create custom control same as multiple monitor control that manages monitors windows (From: "Gami Ravi" <email@hidden>)

  • Prev by Date: Re: Mac Pro memory sizes
  • Next by Date: Re: Security With Show Package Contents?
  • Previous by thread: create custom control same as multiple monitor control that manages monitors windows
  • Next by thread: Re: create custom control same as multiple monitor control that manages monitors windows
  • Index(es):
    • Date
    • Thread