NsIFilePicker: Difference between revisions
From MozillaZine Knowledge Base
Jump to navigationJump to search
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{extdev}} | |||
==Using nsIFilePicker== | ==Using nsIFilePicker== | ||
Line 25: | Line 27: | ||
{{msg:stub}} | {{msg:stub}} | ||
[[Category:Development]] |
Revision as of 03:16, 19 December 2004
This page is part of the extension development documentation project.
Ask your questions in MozillaZine Forums. Also try browsing example code.
Note: development documentation is in process of being moved to Mozilla Development Center (MDC).
Using nsIFilePicker
const nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"] .createInstance(nsIFilePicker); fp.init(window, "Dialog Title", nsIFilePicker.modeOpen); fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText); var rv = fp.show(); if (rv == nsIFilePicker.returnOK) { var file = fp.file; // work with returned nsILocalFile... }
Notes
- If you pass empty string as dialog title, the dialog will have default title
- When checking return value for Save dialog, be sure to check for nsIFilePicker.returnReplace too.
- Available modes: modeOpen, modeSave, modeGetFolder, modeOpenMultiple.
- Available filters: filterAll, filterHTML, filterText, filterImages, filterXML, filterXUL, filterApps.