Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > making file browse button in IB?

making file browse button in IB?
Thread Tools
Dedicated MacNNer
Join Date: Jan 2001
Status: Offline
Reply With Quote
Dec 31, 2001, 11:19 AM
 
I am just making a really simple app to try out using PB/IB to wrap a CLI tool with a GUI. Right now I've got it so there's a text box where you can enter a file name, and a button to hit to process it.

What I'd like to do is instead of the text box have one of those things that's a text box with a button next to it, and if you hit the button(usually called "Browse") it opens like an Open File dialog, and lets you select a file, and once you do it puts the path in the text box.

Can anyone tell me(in fairly good detail - I never touched IB before last night) how to do this, or even better point me to a code example?
"You have violated the spelling of the DMCA and will be jailed with the Village People."
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Dec 31, 2001, 12:19 PM
 
One word: NSOpenPanel

Short and skinny, you need to create a method in your controller object that will make an NSOpenPanel (the documentation on this is really clear and simple) and then return what file if any is selected in the NSOpenPanel. Then link your button's action to that method and do whatever stuff you need to do.

HTH,
F-bacher
     
crayz  (op)
Dedicated MacNNer
Join Date: Jan 2001
Status: Offline
Reply With Quote
Dec 31, 2001, 02:00 PM
 
OK I've got it so there's a button, and when you press the button an open dialog appears, and I think my code for getting the file name from that dialog should work, but now how do I:
a) update the text box so that it displays the path of the file that was selected and
b) make it so that file(as a string) is used as the argument for opening the CLI tool?

I really have no clue on the first. For the second I tried:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>[CLItool setArguments:file];</font>[/code]

But that doesn't work

Before it was:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>[CLItool setArguments:[NSArray arrayWithObject:[fileFolder stringValue]]];</font>[/code]

fileFolder being an IBOutlet for the text box

I know this is newbie stuff but can anyone help?

[ 12-31-2001: Message edited by: crayz ]
"You have violated the spelling of the DMCA and will be jailed with the Village People."
     
crayz  (op)
Dedicated MacNNer
Join Date: Jan 2001
Status: Offline
Reply With Quote
Dec 31, 2001, 05:04 PM
 
Never mind, I found out what the problem was.
"You have violated the spelling of the DMCA and will be jailed with the Village People."
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:26 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2