Dragging + Selectors

ededed
Unregistered
 
Post: #1
I was having some trouble with a game I am making, MASTERMIND.

I wanted to drag an NSView but I didnt know how to do it so I ended up stetting the cursor to a small colored circle.

I also wanted to use selectors but I am sort of stuck there too. I fixed the problem I had another way but badly.

There are 5 CircleView:NSView
And a GameView:NSView

The gameview has 5 outlets
red, green, blue, orange and pink

on init it sets all their colors and tooltips but It should set a selector so that when a CircleView gets dragged it should call a method with two parameters giving the NSEvent* and a NSColor.

It's going to be a free open source thing when its finished by the way. Grin
Quote this message in a reply
furballphat
Unregistered
 
Post: #2
Don't try to move views around, just make one big view to contain all your images abd do some custom dragging code.

What can't you do with selectors?
Quote this message in a reply
ededed
Unregistered
 
Post: #3
Using selectors would not be an issue if you were using one big view for everything but I wanted to have 5 views that would let you drag a color out of them. You could drag the color onto the main view. I would need selectors from the main view to detect mouse dragged events so that you would see where you were going to drop the color before you did.

In the code just now when you drag a peg the cursor changes from the arrow to a small ball the color of the peg but I really want to be able to drag an Image and then have the NSDraggingPasteboard set to the correct color. This would mean that you could play from the color picker to my mastermind game.
Quote this message in a reply
Member
Posts: 196
Joined: 2002.04
Post: #4
I don't really understand what you're talking about. Maybe you should give a source code example if it's still not fixed. I'm not too sure of what you're talking about but you should probably try this game that comes with source code-Quartzeroids is a royalty free game which explains the subviews and loading images. I think it's on idev's source code page or you could search for it at versiontracker.com.

Hope this helps,
Iceman
Quote this message in a reply
ededed
Unregistered
 
Post: #5
Quartzeroids is good fun but I know how to use NSViews and SubViews. The problem is I want to be able to have an NSImage that will be dragged around with the cursor.

Like when you drag and drop a file. I want to drag and drop a peg for a game like othelo, draughts or chess.

I got selectors working and I will put them in the source code when I GET DRAGGING WORKING.
Quote this message in a reply
ededed
Unregistered
 
Post: #6
PLEASE SOMEONE HELLLLLLP MEEEEEEEEE. I have been stuck on this for longer than any thing else and its such an easy problem I just can do it... and only tried twice but PLEASE. Sad
Quote this message in a reply
ededed
Unregistered
 
Post: #7
Does anyone know how to drag and drop stuff?
Quote this message in a reply
Jeff Binder
Unregistered
 
Post: #8
What exactly are you trying to accomplish? If you need to drag between windows or views, Cocoa's drag and drop is what you want, but it seems that you're better off doing it yourself. Once you have a custom view you can draw and handle events, you should be able to manage it.

Just keep an array of objects, and keep track of which item is being dragged, if any. So when you get a mouse down event, check if it hit any item, and if so, it becomes the dragged item. A mouse up event clears the dragged item (set it to -1 or something). If you get a mouse dragged event, and something is being dragged, change its position to the new mouse location. The items you have should be object, but not necessarily views.

This gives you more control, and likely will be faster than using views. Try it, and if you have trouble then post the code and I'll look at it.
Quote this message in a reply
ededed
Unregistered
 
Post: #9
Thanks JeffBinder. I want to drag between windows and applications. Most people could code a drag and drop system but It would only work within the confines of the NSView.

I really really really want to drag have an NSImage snap the the cursor like when you drag a file or a color swatch or a piece of text. I can do everything with NSPasteboards and all that rubbish inbetween but I want the code for the mouseDown event

Sorry for being so angry but I just cannot do this myself and it is so ANNOYING.
Seriously though thanks for your idea but its no what I want.
Quote this message in a reply
Member
Posts: 196
Joined: 2002.04
Post: #10
Ok maybe this code will help: http://www.macdevcenter.com/pub/a/mac/20...cocoa.html
It's an O'Reilly tutorial called scrach pad which teaches you how to use keydown and mousedown events. It's kind of basic but it may be just enough. Also check out the other tutorials that mike beam has done: http://macdevcenter.com/pub/ct/37 .

Hope this helps Smile
Iceman
Quote this message in a reply
ededed
Unregistered
 
Post: #11
NO MAYBE THAT CODE WONT HELP

I AM NOT STUPID I KNOW HOW TO DO MOST THINGS WITH COCOA, I DONT NEED A TUTORIAL ON MOUSE EVENTS OK!!!!!!!!!!!!!! THE ONLY THING I CANT DO IS GET A DRAG AND DROP SYSTEM. I DONT WANT TO MAKE MY OWN DND SYSTEM BECAUSE THEN EVERYTING WOULD BE CONFINED TO THE VIEW YOU IDIOT. I WANT TO DRAG AN IMAGE ABOUT. IS THAT TO HARD FOR ANYONE TO UNDERSTAND IF YOU CANT HELP DONT TRY. ALL I NEED TO FINISH THIS RUBBISH GAME IS TO GET DRAGGING AND DROPPING WORKING I DONT WANT ANYTHING AND I CANT GET ANYTHING FROM A BUNCH OF TUTORIALS ABOUT GREEN BLOBS AND "intellegent zooming action!!!!

IS EVERYONE STUPID OR WHAT?


Mad
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #12
:eek: Sorry if I am a tad out of line saying this but... it seems to me that everyone is trying their best to help you out. So why the above post?
Quote this message in a reply
ededed
Unregistered
 
Post: #13
You are not out of line that was me.
Sorry to everyone involved. BUT I HATE THIS!!!!!.

I would like to say I have everyting working except dragging I need not a SKETCH PAD. I just want to attach a NSImage to the NSCursor and everything else wil be NSOk. OK?

Sorry ICE MAN:
Quote:It's kind of basic but it may be just enough.
No..
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #14
Found the solution:
[Image: mountain.jpg]

And a very in-depth tutorial to expand on it.

Good Luck!
-Jon
Quote this message in a reply
furballphat
Unregistered
 
Post: #15
Is this what you're looking for? http://developer.apple.com/techpubs/maco...index.html

With that much desperation I'm surprised you didn't just look in the programing topics of project builder's help

And no, we're not stupid, just intellectually challenged.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa: Mouse location while dragging window Fenris 4 4,871 Jul 14, 2005 04:46 PM
Last Post: Fenris