Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 16, 2008, 10:07 PM   #1
sirjorj
macrumors newbie
 
Join Date: Oct 2007
How to drop a file anywhere on the window

Hi. I am fairly new to Cocoa programming and I have a problem that I have not been able to figure out. I have a simple little Cocoa app consisting of a TableView and a multiline TextField and I want to be able to drop a file anywhere on the app. I have made an app that would accept drop on a textfield, but now I want to be able to drop it anywhere on the window.

First I tried selecting the main view in Interface Builder and changing the class to DroppableView (a class I made subclassed from NSView to implement the drag/drop handlers) but initWithFrame would never fire when I run the program.

Then I returned the class to NSView and covered it with a CustomView control and set its class to DroppableView. This would fire the initWithFrame controls, but the TableView and TextField that I had on top of the control were no longer visible.

This shouldn't be that complicated of a thing to do, but I am out of ideas. Any help?

jorj
sirjorj is offline   0 Reply With Quote
Old Nov 16, 2008, 10:36 PM   #2
kainjow
Demi-God (Moderator emeritus)
 
kainjow's Avatar
 
Join Date: Jun 2000
Stick with your original idea but override initWithCoder: instead.
kainjow is offline   0 Reply With Quote
Old Nov 17, 2008, 06:29 PM   #3
sirjorj
Thread Starter
macrumors newbie
 
Join Date: Oct 2007
Thanks a ton! I have been looking for that for a while!

UPDATE: Now the view catches the events but the TableView and TextField I have on it are not visible at runtime. Do I have to programmatically add them since I overrode the view?

ANOTHER UPDATE: never mind - I wasn't calling super's init - now it works

jorj

Last edited by sirjorj; Nov 17, 2008 at 08:42 PM.
sirjorj is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to make PDF files created on PC read properly on a MAC kelhami Mac OS X 12 Aug 12, 2011 03:29 PM
How to open a file dialog before the Main window display? MayPeng Mac Programming 3 Dec 9, 2010 09:31 PM
Tip: How to copy/move files with only one window n8mac Mac OS X 2 Jan 6, 2009 06:43 PM
How to Download IPA Files And Preserve the File Extension kevhui Mac Basics and Help 3 Dec 22, 2008 11:46 PM


All times are GMT -5. The time now is 11:52 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC