tips
[Top] [All Lists]

REALbasic Tip: Selecting and launching Mac OS X applications

To: "REALbasic Tips" <realbasic-tips at lists dot realsoftware dot com>
Subject: REALbasic Tip: Selecting and launching Mac OS X applications
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Wed, 02 Apr 2003 10:02:59 -0600
You've probably used the GetOpenFolderItem function to display an open file
dialog box so the user can select a file. This can also be used (with the
appropriate file type) to select applications. On Mac OS X however, not all
applications are the same. Some applications (like Mail for example) come in
"package" form. This means that the item the user selects in the Finder is
not in fact a file but is actually a special type of folder that represents
the application. Unfortunately, the GetOpenFolderItem function does not
support application packages.

The good news is the OpenDialog class does. The OpenDialog class was
designed to provide a more powerful and flexible way to present an open file
dialog. Given that you've added the "application/binary" file type to your
project, the following code will present an open file dialog box, let the
user choose any file and then launch it:

  dim f As FolderItem
  dim d as OpenDialog
  d = new OpenDialog
  d.Filter = "application/binary"
  f = d.ShowModal
  if f <> nil then
    f.Launch
  end if

There are also SelectFolderDialog and SaveAsDialog classes as well. These
three new dialog classes were added in REALbasic version 3.5.

This tip was inspired by Stephen Schleick.
-- 
Geoff Perlman
President and CEO
REAL Software, Inc.
512-328-7325 x711 (voice)
512-328-7372 (fax)


 - - - - - - - - - -
Got a useful tip to share? Send it to us at:
<REALbasic-tips at lists dot realsoftware dot com>.

To unsubscribe from the Tips list, send an email to 
<mailto:realbasic-tips-off at lists dot realsoftware dot com>

<Prev in Thread] Current Thread [Next in Thread>
  • REALbasic Tip: Selecting and launching Mac OS X applications, Geoff Perlman <=