Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / August 2004



Tip: Looking for answers? Try searching our database.

NSOpenPanel and CamelBones

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan Olsen - 13 Jul 2004 02:12 GMT
Does anyone have a good snippet of example code for calling NSOpenPanel
with CamelBones?

I am not certain what the syntax should be and there are few examples I
can find.

Thanks!
Alan Olsen - 13 Jul 2004 02:36 GMT
> Does anyone have a good snippet of example code for calling
> NSOpenPanel with CamelBones?
>
> I am not certain what the syntax should be and there are few examples
> I can find.

It figures that I have to post here to find where the examples are kept.

"Never mind!"
Thilo Planz - 13 Jul 2004 04:59 GMT
Hi,

> Does anyone have a good snippet of example code for calling
> NSOpenPanel with CamelBones?
>
> I am not certain what the syntax should be and there are few examples
> I can find.

Did you check Apple's Cocoa Documentation?
Since CamelBones just wraps around the Objective-C functions, you can
use the documentation for that.

For starters, you can do something like this:

> my $panel = NSOpenPanel->openPanel;
> if ($panel->runModal) {
[quoted text clipped - 9 lines]
>
> }

There is also NSSavePanel to save files (rather than open them).

If you want to filter for specific files types you can do:

>  my $types = NSMutableArray->alloc->init;
>     $types->addObject('pod');
[quoted text clipped - 4 lines]
>
>     if ($panel->runModalForTypes($types)) {

Hope it helps,

Thilo
Alan Olsen - 30 Jul 2004 20:38 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> Since CamelBones just wraps around the Objective-C functions, you can
> use the documentation for that.

Sometimes that works, sometimes it does not.  It seems that a lot of
trial and error is involved.

> For starters, you can do something like this:
>
[quoted text clipped - 13 lines]
>
> There is also NSSavePanel to save files (rather than open them).

BTW, this example is much more to the point than those in the example
programs.  Much more commented as well.  (The examples assume that you
are already proficient at Cocoa and Objective-C.)

> If you want to filter for specific files types you can do:
>
[quoted text clipped - 6 lines]
>>
>>     if ($panel->runModalForTypes($types)) {

How do I get the open and/or save dialog to open at a specific
directory?  What I have tried has not worked.
Thilo Planz - 04 Aug 2004 01:43 GMT
>>>  my $types = NSMutableArray->alloc->init;
>>>     $types->addObject('pod');
[quoted text clipped - 7 lines]
> How do I get the open and/or save dialog to open at a specific
> directory?  What I have tried has not worked.

That is pretty straightforward (it is explained in the Cocoa API
documents for Objective C )

> my $types = NSMutableArray->alloc->init;
>     $types->addObject('pod');
[quoted text clipped - 5 lines]
> my $result = $panel->runModalForDirectory_file_types('/Applications/',
> undef,$types);

Shameless plug:

You can try out this kind of code very quickly using PerlPad.
http://perl-pad.sourceforge.net/

Just copy & paste the above lines into PerlPad and see your NSOpenPanel
in action.
Much faster than a full compile cycle in ProjectBuilder.

Thilo
Pierre Vaudrey - 13 Jul 2004 05:33 GMT
Le mardi, 13 jul 2004, à 03:12 Europe/Paris, Alan Olsen a écrit :

> good snippet of example code for calling NSOpenPanel with CamelBones?
http://cvs.sourceforge.net/viewcvs.py/camelbones/CBExamples/FileViewer/
Hope it's useful

Pierre
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.