[MacRuby-devel] C-level blocks (issue #712)?

Matt Aimonetti mattaimonetti at gmail.com
Sun Jan 9 08:23:06 PST 2011


Here is an example of how to use NSOpenPanel:

https://github.com/mattetti/pastis/blob/master/app/Pastis/filter_window_controller.rb#L145-160

  def browse(sender)

    dialog = NSOpenPanel.openPanel

    # Disable the selection of files in the dialog.
    dialog.canChooseFiles = false
    # Enable the selection of directories in the dialog.

    dialog.canChooseDirectories = true

    # Disable the selection of multiple items in the dialog.
    dialog.allowsMultipleSelection = false

    # Display the dialog and process the selected folder
    if dialog.runModalForDirectory(nil, file:nil) == NSOKButton
      selection = dialog.filenames.first
      location.stringValue = dialog.filenames.first.to_s
    end
  end

- Matt

On Sun, Jan 9, 2011 at 8:09 AM, Rolando Abarca <rolando at gamesforfood.com>wrote:

> Hi all,
>
> I've taken a look at the referred issue (#712), but I'm not sure of
> the final implemented syntax. I'm trying to use a NSOpenPanel, so far
> this is what I'm doing:
>
>
> {{{
>  def loadSprite(sender)
>    @panel.beginSheetModalForWindow(@window, completionHandler:lambda {
> |code|
>      NSLog("code: #{code}")
>    })
>  end
> }}}
>
> what's the Right Way(tm) to use a NSOpenPanel?
> thanks!
> --
> Rolando Abarca M.
> Games For Food S.p.A.
> http://www.gamesforfood.com
> Phone: +1 (408) 345-5433
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110109/0e90de5f/attachment.html>


More information about the MacRuby-devel mailing list