Dragging Views and Cursor
Dragging Views and Cursor
- Subject: Dragging Views and Cursor
- From: Seth Willits <email@hidden>
- Date: Fri, 9 Apr 2004 17:29:18 -0700
I have a custom view which contains a number of subviews (they're tabs
in a completely custom tab view) neatly positioned inside of it. I'd
like these views to be moved around within their superview by dragging
and dropping them when the user command-click/drags on those views.
Because the tabs are opaque, the mouse interaction is handled by the
tab itself and will have to send a notification to the tab view to
reorder the tabs. Steps I'll need to take to get the drag working
include:
1) Change the cursor to the grabby-hand when the cursor is inside a tab
AND ONLY if the command key is down. I don't see how to do this since
the only cursor methods in NSView is addCursorRect:cursor. There may be
a work around to simply change the global cursor when it enter/exits
the view, but my mouseEntered/Exited events _refuse_ to fire despite
adding a tracking rectangle.
2) During the drag, drawing where the tab would drop or, preferably,
making the tabs move about like toolbar items do when you drag them
around would be extremely nice, but is not necessary. How to either of
these is beyond me (particularly the latter).
3) When the mouse button is released, get the view which is currently
under the mouse. This would probably be done using [[self superview]
hitTest:point].
4) Once I know which view is under the mouse when the button is
released, I can send a notification to the tab view to reorder the
tabs. This part will be easy, it's 1 through 3 I'm not sure how to do.
If you care to see what I've accomplished so far, you can download this
small little sample app:
<
http://www.freaksw.com/MultiViewTest.app.sit>
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software -
http://www.freaksw.com
REALbasic Guru at ResExcellence -
http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central -
http://www.freaksw.com/rbgames
"No electrons were hurt in the transfer of this e-mail."
-- Anon
------------------------------------------------------------------------
---
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.