[Mono-list] modal FileChooserDialog from FileChooserButton
dafnis
dafnis at ono.com
Thu May 18 13:51:35 EDT 2006
Hi all,
I started learning some C# just two weeks ago and this is the first
issue I can't solve reading the documentation, lists, etc.
I want the Dialog that pops when you select "Other..." from a
FileChooserButton to be modal.
I've tried the following:
FileChooserDialog dialog= new FileChooserDialog(
"Choose Output Directory",
window,
FileChooserAction.SelectFolder,
Stock.Cancel,
ResponseType.Cancel,
Stock.Open,
ResponseType.Ok,
null);
dialog.Modal = true;
dialog.DestroyWithParent = false;
fcdOut.SelectMultiple = false;
FileChooserButton button = new FileChooserButton(dialog);
but the Dialog is not modal, it stays on top but I still can interact
with the main window.
If I use this constructor:
FileChooserButton button = new FileChooserButton("Choose Output Directory",
FileChooserAction.SelectFolder);
the Dialog is not modal, and I have no clue of how to access the
properties of the underlying FileChooserDialog when using this last
constructor.
If I use a FileChooserDialog linked to a 'normal' Button instead of a
FileChooserButton the Dialog is modal as expected:
Button bt = new Button("Add Files");
bt.Clicked += new EventHandler(bt_Clicked);
//...
static void bt_Clicked(object sender, EventArgs e)
{
FileChooserDialog fcd = new FileChooserDialog(
"Choose some files or directories to process",
window,
FileChooserAction.Open,
Stock.Cancel,
ResponseType.Cancel,
Stock.Open,
ResponseType.Ok,
null);
fcd.SelectMultiple = true;
fcd.DestroyWithParent = true;
fcd.Modal = true;
if((ResponseType)fcd.Run() == ResponseType.Ok) {
foreach(string x in fcd.Filenames) {
someListStore.AppendValues(x);
}
}
fcd.Destroy();
}
I know it would be easier to use the above code to select a directory,
but I prefer to learn new things.
Dafnis
More information about the Mono-list
mailing list