Second Try - Call modal dialog from modal dialog 
Author Message
 Second Try - Call modal dialog from modal dialog

Not wanting to look pushy or impatient...... but not yet seeing a response,
I try again...

  ;^)

Jeff

======================

Hi All,

My Vitals:
Tcl 8.4 (actually, ActiveTCL), Win98, Bwidgets 1.4.1

My Problem:
I have a TK toplevel, that calls a BWidget Dialog widget.  This widget is
modal in that I can't access the toplevel until the BW Dialog is closed.
This is correct and expected.  Now, from the BW Dialog, I can press a
"Browse..." button which calls [tk_chooseDirectory].  I expect the directory
chooser dialog to also be "modal" in nature.  That is, I don't want to be
able to interact with the BW Dialog until the directory chooser dialog is
closed.  This does not work.  I can still set focus on, and interact with,
the BW Dialog when the tk_chooseDirectory dialog is open.  I can even press
the "Browse..." button one or more times to generate "stacked" directory
chooser dialogs.

As a test, I placed a "Browse..." button in a TK toplevel which calls
[tk_chooseDirectory].  This works as expected.  That is, I cannot interact
with the toplevel until the directory chooser is closed.  I don't know if my
problem is related to the BW Dialog widget specifically, or if is a more
general problem related to calling a modal dialog from a modal dialog, as I
am not overly versed in the use of (and dangers of) [grab].

I have noticed the BW Dialog widget accepts a "-modal" option, and can be
set to none, local, or global.  I have experimented with these, but have not
found any to provide the behavior I expect.

Any ideas?

Thanks,

Jeff



Sun, 08 May 2005 04:45:34 GMT  
 Second Try - Call modal dialog from modal dialog

Quote:

> Not wanting to look pushy or impatient...... but not yet seeing a
> response,
> I try again...

>   ;^)

> Jeff

> ======================

> Hi All,

> My Vitals:
> Tcl 8.4 (actually, ActiveTCL), Win98, Bwidgets 1.4.1

> My Problem:
> I have a TK toplevel, that calls a BWidget Dialog widget.  This widget is
> modal in that I can't access the toplevel until the BW Dialog is closed.
> This is correct and expected.  Now, from the BW Dialog, I can press a
> "Browse..." button which calls [tk_chooseDirectory].  I expect the
> directory
> chooser dialog to also be "modal" in nature.  That is, I don't want to be
> able to interact with the BW Dialog until the directory chooser dialog is
> closed.  This does not work.  I can still set focus on, and interact with,
> the BW Dialog when the tk_chooseDirectory dialog is open.  I can even
> press
> the "Browse..." button one or more times to generate "stacked" directory
> chooser dialogs.

> As a test, I placed a "Browse..." button in a TK toplevel which calls
> [tk_chooseDirectory].  This works as expected.  That is, I cannot interact
> with the toplevel until the directory chooser is closed.  I don't know
> if my
> problem is related to the BW Dialog widget specifically, or if is a more
> general problem related to calling a modal dialog from a modal dialog,
> as I
> am not overly versed in the use of (and dangers of) [grab].

> I have noticed the BW Dialog widget accepts a "-modal" option, and can be
> set to none, local, or global.  I have experimented with these, but
> have not
> found any to provide the behavior I expect.

> Any ideas?

> Thanks,

> Jeff

Jeff, I haven't used BWidgets, but I suspect the problem happens when
[grab] is not released when the file chooser is opened.  Were this my
challenge, I would read "man n grab" and the source for that particular
BWidget.

-- Luke Kale Myers



Sun, 08 May 2005 08:34:17 GMT  
 Second Try - Call modal dialog from modal dialog

Quote:

> My Problem:
> I have a TK toplevel, that calls a BWidget Dialog widget.  This widget is
> modal in that I can't access the toplevel until the BW Dialog is closed.
> This is correct and expected.  Now, from the BW Dialog, I can press a
> "Browse..." button which calls [tk_chooseDirectory].  I expect the directory
> chooser dialog to also be "modal" in nature.  That is, I don't want to be
> able to interact with the BW Dialog until the directory chooser dialog is
> closed.  This does not work.  I can still set focus on, and interact with,
> the BW Dialog when the tk_chooseDirectory dialog is open.  I can even press
> the "Browse..." button one or more times to generate "stacked" directory
> chooser dialogs.

> As a test, I placed a "Browse..." button in a TK toplevel which calls
> [tk_chooseDirectory].  This works as expected.  That is, I cannot interact
> with the toplevel until the directory chooser is closed.  I don't know if my
> problem is related to the BW Dialog widget specifically, or if is a more
> general problem related to calling a modal dialog from a modal dialog, as I
> am not overly versed in the use of (and dangers of) [grab].

> I have noticed the BW Dialog widget accepts a "-modal" option, and can be
> set to none, local, or global.  I have experimented with these, but have not
> found any to provide the behavior I expect.

Jeff,

Can you post a short snippet of code that demonstrates the problem?

Mark /

--
Mark G. Saye



Sun, 08 May 2005 08:43:03 GMT  
 Second Try - Call modal dialog from modal dialog


Quote:
> Can you post a short snippet of code that demonstrates the problem?

> Mark /

Mark,

Here is an example that shows what I am talking about.  Note that when the
Browse button is pressed on the toplevel, the directory chooser is truly
modal - you can't interact with the toplevel until the chooser is closed.
When the Browse button is pressed from within the BW Dialog, the chooser *is
not* modal - you can still focus and interact with the BW Dialog  and even
open up multiple copies of the directory chooser.

I tried this under Linux tonight and *do not* notice this odd behavior.
That is, the directory chooser works as expected in both cases.  I know that
[tk_chooseDirectory] is TK code under *nix, so I'm guessing the problem is
somehow related to the native MS dialogs?  Also, I replaced
[tk_chooseDirectory] with [tk_getOpenFile] and got the same result.

Thanks for any input.

Jeff

====== CODE BELOW =======

package require BWidget

button .b1 -text "Browse..." -width 10 -command tk_chooseDirectory
button .b2 -text "BW Dialog..." -width 10 -command showDialog
pack .b1 .b2

proc showDialog {} {

    set dlg [Dialog .dialog \
        -title "Test" \
        -anchor e \
        -parent . \
        -default 0 \
        -cancel 1 \
        -place center \
        -separator 1 ]
    $dlg add -text "OK" -width 10
    $dlg add -text "Cancel" -width 10
    set frame [$dlg getframe]
    button $dlg.b1 -text "Browse..." -command tk_chooseDirectory
    pack $dlg.b1

    set retval [$dlg draw]
    destroy $dlg

Quote:
}



Sun, 08 May 2005 09:53:46 GMT  
 Second Try - Call modal dialog from modal dialog

Quote:

> Mark,

> Here is an example that shows what I am talking about.  Note that when the
> Browse button is pressed on the toplevel, the directory chooser is truly
> modal - you can't interact with the toplevel until the chooser is closed.
> When the Browse button is pressed from within the BW Dialog, the chooser *is
> not* modal - you can still focus and interact with the BW Dialog  and even
> open up multiple copies of the directory chooser.

> I tried this under Linux tonight and *do not* notice this odd behavior.
> That is, the directory chooser works as expected in both cases.  I know that
> [tk_chooseDirectory] is TK code under *nix, so I'm guessing the problem is
> somehow related to the native MS dialogs?  Also, I replaced
> [tk_chooseDirectory] with [tk_getOpenFile] and got the same result.

> Thanks for any input.

> Jeff

> ====== CODE BELOW =======

> package require BWidget

> button .b1 -text "Browse..." -width 10 -command tk_chooseDirectory
> button .b2 -text "BW Dialog..." -width 10 -command showDialog
> pack .b1 .b2

> proc showDialog {} {

>     set dlg [Dialog .dialog \
>         -title "Test" \
>         -anchor e \
>         -parent . \
>         -default 0 \
>         -cancel 1 \
>         -place center \
>         -separator 1 ]
>     $dlg add -text "OK" -width 10
>     $dlg add -text "Cancel" -width 10
>     set frame [$dlg getframe]
>     button $dlg.b1 -text "Browse..." -command tk_chooseDirectory
>     pack $dlg.b1

>     set retval [$dlg draw]
>     destroy $dlg
> }

I think you should be able to fix the problem by making the chooser
(spawned from the dialog) modal to .dialog (instead of to .). You can do
this by passing the -parent option to tk_chooseDirectory. In other
words, replace

button $dlg.b1 -text "Browse..." -command tk_chooseDirectory

with

button $dlg.b1 -text "Browse..." \
   -command [list tk_chooseDirectory -parent .dialog]

In my limited testing, this seems to work on Linux and Windows. I hope
it works for you, too. Let me know ...

Regards,

Mark /

--
Mark G. Saye



Sun, 08 May 2005 10:20:16 GMT  
 Second Try - Call modal dialog from modal dialog


Quote:

> I think you should be able to fix the problem by making the chooser
> (spawned from the dialog) modal to .dialog (instead of to .). You can do
> this by passing the -parent option to tk_chooseDirectory. In other
> words, replace

> button $dlg.b1 -text "Browse..." -command tk_chooseDirectory

> with

> button $dlg.b1 -text "Browse..." \
>    -command [list tk_chooseDirectory -parent .dialog]

> In my limited testing, this seems to work on Linux and Windows. I hope
> it works for you, too. Let me know ...

Mark,

Perfect!  As you suspected, I had the [tk_chooseDirectory] dialog
mis-parented...  Nice catch.  I haven't retested under Linux yet, but it
definitely fixed the problem under Windows.

Thanks for the help.

Jeff



Sun, 08 May 2005 10:35:35 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Call modal dialog from modal dialog?

2. modal dialog windows in ENFIN (os/2)

3. Testing MVC application with Modal Dialogs

4. Resizable modal dialogs!

5. How to get a true modal dialog in OS X

6. Menubar not refreshed when closing a modal dialog

7. plainDBox modal dialogs?

8. Proper way to retrieve value from modal dialog?

9. Window-Modal Dialog Boxes

10. Modal dialog boxes

11. modal dialog in VA5.5 with WBPro

12. Completely Modal Dialog Box

 

 
Powered by phpBB® Forum Software