XmCreateFileSelectionDialog won't close upon clicking OK - Xwindows

This is a discussion on XmCreateFileSelectionDialog won't close upon clicking OK - Xwindows ; I have to pull apart a legacy application and make some mofications. The following section of code will launch a file open dialog box, which allows me to choose a file and click "OK". However the funny thing is after ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: XmCreateFileSelectionDialog won't close upon clicking OK

  1. XmCreateFileSelectionDialog won't close upon clicking OK

    I have to pull apart a legacy application and make some mofications.
    The following section of code will launch a file open dialog box,
    which allows me to choose a file and click "OK". However the funny
    thing is after I click OK the dialog box is still open. How do I set
    it up so that after I choose the file and click OK, the dialog box
    will automatically close? Thx

    Please forgive me if this is a frequently asked question. I rarely
    touch motif


    EXCERPT
    ------------------------------------------------------------------------------------------------------------------
    tcs = XmStringCreateLtoR("*.m1", charset);
    XtSetArg(args[n], XmNpattern, tcs); n++;
    open_dialog = XmCreateFileSelectionDialog(top_level,
    "Model Open", args,
    n);
    XtAddCallback( open_dialog, XmNcancelCallback, cancel_cb,
    NULL);
    XtAddCallback( open_dialog, XmNokCallback, file_select_cb,
    NULL);
    XtManageChild(open_dialog);
    XmStringFree(tcs);

  2. Re: XmCreateFileSelectionDialog won't close upon clicking OK

    Joseph wrote:
    > I have to pull apart a legacy application and make some mofications.
    > The following section of code will launch a file open dialog box,
    > which allows me to choose a file and click "OK". However the funny
    > thing is after I click OK the dialog box is still open. How do I set
    > it up so that after I choose the file and click OK, the dialog box
    > will automatically close? Thx


    Try setting XmNautoUnmanage to TRUE

    DuĊĦan Peterc

  3. Re: XmCreateFileSelectionDialog won't close upon clicking OK

    On Feb 5, 3:46*pm, Joseph wrote:
    > I have to pull apart a legacy application and make some mofications.
    > The following section of code will launch a file open dialog box,
    > which allows me to choose a file and click "OK". *However the funny
    > thing is after I click OK the dialog box is still open. *How do I set
    > it up so that after I choose the file and click OK, the dialog box
    > will automatically close? *Thx
    >
    > Please forgive me if this is a frequently asked question. *I rarely
    > touch motif
    >
    > EXCERPT
    > ---------------------------------------------------------------------------*---------------------------------------
    > * * * * tcs = XmStringCreateLtoR("*.m1", charset);
    > * * * * XtSetArg(args[n], XmNpattern, tcs); n++;
    > * * * * open_dialog = XmCreateFileSelectionDialog(top_level,
    > * * * * * * * * * * * * * * * * * * * * * * * * * "Model Open", args,
    > n);
    > * * * * XtAddCallback( open_dialog, XmNcancelCallback, cancel_cb,
    > NULL);
    > * * * * XtAddCallback( open_dialog, XmNokCallback, file_select_cb,
    > NULL);
    > * * * * XtManageChild(open_dialog);
    > * * * * XmStringFree(tcs);


    Unmanage it in both the OK and Cancel callbacks. The drawback to
    having it
    auto-unmanaged is: what happens if the user types in a bad file name,
    then clicks OK? the dialog is dismissed, the app tries to open the non-
    existing
    file, and then what??

    Better to try opening the file in the OK callback, and if successful
    then you
    unmanage the dialog. If unsuccessful, you notify the user - and the
    file selection box is still visible, so she can see the erroneous
    name,
    fix it, and try again..
    --
    Fred Kleinschmidt

+ Reply to Thread