allowedFileTypes and NSOpenPanel
Hi, I try to use setAllowedFileTypes with an NSOpenPanel using this code : panel = NSOpenPanel.openPanel() panel.canChooseFiles = true panel.allowedFileTypes = ["graphml", "gml", "xml"] result = panel.runModal() But it doesn't work. I can chose any type of file. If I use the (10.6) deprecated runModalWithTypes, it works... So is it me or setAllowedFileTypes which's buggy ? Thanks for your help. Greg
Here is an extract from one of my apps: def browse(sender) # Create the File Open Dialog class. 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 Note that location is an attr_accessor that I have and the the #browser method gets called when pushing a button. I hope that helps. - Matt On Sat, Nov 13, 2010 at 7:38 AM, Gregoire LEJEUNE < gregoire.lejeune@gmail.com> wrote:
Hi,
I try to use setAllowedFileTypes with an NSOpenPanel using this code :
panel = NSOpenPanel.openPanel() panel.canChooseFiles = true panel.allowedFileTypes = ["graphml", "gml", "xml"] result = panel.runModal()
But it doesn't work. I can chose any type of file.
If I use the (10.6) deprecated runModalWithTypes, it works... So is it me or setAllowedFileTypes which's buggy ?
Thanks for your help.
Greg _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Gregoire, I ran your snippet from the terminal and the panel was only able to select these file types, in my environment. What version of Mac OS X do you run? It's possible that there is a Cocoa bug somewhere. Laurent On Nov 13, 2010, at 5:38 AM, Gregoire LEJEUNE wrote:
Hi,
I try to use setAllowedFileTypes with an NSOpenPanel using this code :
panel = NSOpenPanel.openPanel() panel.canChooseFiles = true panel.allowedFileTypes = ["graphml", "gml", "xml"] result = panel.runModal()
But it doesn't work. I can chose any type of file.
If I use the (10.6) deprecated runModalWithTypes, it works... So is it me or setAllowedFileTypes which's buggy ?
Thanks for your help.
Greg _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Laurent, I use Mac OS X 10.6.5, MacRuby 0.7, Xcode 3.2.5. Greg 2010/11/22 Laurent Sansonetti <lsansonetti@apple.com>:
Hi Gregoire, I ran your snippet from the terminal and the panel was only able to select these file types, in my environment. What version of Mac OS X do you run? It's possible that there is a Cocoa bug somewhere. Laurent On Nov 13, 2010, at 5:38 AM, Gregoire LEJEUNE wrote:
Hi,
I try to use setAllowedFileTypes with an NSOpenPanel using this code :
panel = NSOpenPanel.openPanel() panel.canChooseFiles = true panel.allowedFileTypes = ["graphml", "gml", "xml"] result = panel.runModal()
But it doesn't work. I can chose any type of file.
If I use the (10.6) deprecated runModalWithTypes, it works... So is it me or setAllowedFileTypes which's buggy ?
Thanks for your help.
Greg _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Gregoire LEJEUNE
-
Laurent Sansonetti
-
Matt Aimonetti