How to create a draggable view a la Stickies.app?
How to create a draggable view a la Stickies.app?
- Subject: How to create a draggable view a la Stickies.app?
- From: Keith Blount <email@hidden>
- Date: Fri, 29 Oct 2004 12:08:05 -0700 (PDT)
Hello,
I am currently reworking a notes view I have, which is
placed adjacent to a text view and is intended for
making annotations on what is in the text view - kind
of a margin notes view. I have decided to rework it to
follow the very helpful suggestions that Daniel Todd
Currie and Eric Ocean made to me on this list
previously
(
http://www.cocoabuilder.com/archive/message/cocoa/2004/9/4/116628
and
http://www.cocoabuilder.com/archive/message/cocoa/2004/10/28/120456).
Essentially, the idea is that I have a custom view,
and whenever the user clicks into it, a view very much
like a note in Stickies.app is created. The user can
then type into this note, or drag it elsewhere in the
(margin) view.
Unfortunately, I have fallen at the first hurdle. I
thought it would be relatively easy to create a
subview that could be dragged around, but it is more
complicated than I thought. I have tried setting up
two views:
NoteCard - this is simply a small custom view that
contains a text view.
MarginView - a custom view. If the user clicks on it,
it creates a new NoteCard view as a subview. So far,
so good.
I have set up NoteCard so that on mouseDragged:, it
checks the event's locationInWindow and then changes
the origin of the view using setFrame: accordingly.
This is where things get ugly.
I thought this would do the trick, but it just causes
all sorts of drawing problems - the NoteCard moves
okay(ish - I haven't converted the location point
quite right just yet), but it leaves trails all over
the superview (MarginView), even though the drawRect:
method of MarginView is being called fine and should
be filled in with colour each time the NoteCard is
dragged and thus get rid of the trails (I would have
thought).
Has anybody got any suggestions for how I could set up
subviews that work like the notes in Stickies, or just
some pointers on where to start or where I am going
wrong? I would be very grateful for any helpful tips.
Many thanks,
Keith
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
_______________________________________________
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