Re: create custom control same as multiple monitor control that manages monitors windows
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