RE: Drawing over a view's subviews
RE: Drawing over a view's subviews
- Subject: RE: Drawing over a view's subviews
- From: Keith Blount <email@hidden>
- Date: Wed, 15 Jun 2005 12:02:08 -0700 (PDT)
Hi,
I took a slightly different approach in doing
something similar; I don't know if it will work in
your situation. My view has two subviews next to each
other with a single-pixel line between them, and the
user can grab it and drag it over the top of the
subviews. When the mouse is released, the views resize
to where the line has been moved.
To do this, I just take a snapshot of the subviews
into an NSImage instance variable when the user grabs
the resizing bar (on mouseDown:). Then I retain and
remove the subviews.
In mouseDragged: I set the position of the resizing
bar in a float variable.
In drawRect:, if my NSImage instance variable is nil,
I do normal drawing. If it is not nil, I draw the
snapshot image of the subviews inside the view and
then draw the grab bar at the position set in
mouseDragged: over the top.
In mouseUp:, I release the image and set it to nil,
and restore the subviews back into the view hierachy,
resizing them as necessary.
The code I use to take a snapshot of the view is John
C. Randolph's -snapshot method, which can be found
here:
http://www.cocoabuilder.com/archive/message/2003/8/22/87843
This works well for me - you might be able to adapt
this approach to your needs.
HTH,
Cheers,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
_______________________________________________
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