Centering Progress Dialogs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Centering Progress Dialogs

Jerome Chan
How do I center Progress Dialogs on a ShellView? Looking at the source,
it appears that the ownerView is assumed to be the active window. There
are instances when I could switch to another window before the dialog
comes up and the dialog is modal on the wrong window. How do I
programmatically set the ownerView? I've tried

presenterObject view ownerView: shellViewObjectName

but the dialog still centers on the main desktop.

Anyone with a workaround?


Reply | Threaded
Open this post in threaded view
|

Re: Centering Progress Dialogs

Ian Bartholomew-17
Jerome,

> Anyone with a workaround?

ProgressDialog (like all Dialog Views) has an aspect called
#isInitiallyCentered which controls the initial position of the Dialog - the
default for ProgressDialog is true so the Dialog is centered.

Setting this to false (either programmatically or in the ViewComposer) lets
Windows position the Dialog as it would any newly opened Window. You can
then set the #position aspect of the Dialog and, I suspect, that you will
have to do this if you want to centre the Dialog in a specific Shell.
Something like (this is ProgressDialog>>example1 expanded)

s := Shell show.
p := ProgressDialog create.
p ownerView: s view.
p view
    isInitiallyCentered: false;
    position: s view rectangle center - (p view extent // 2).
p operation: [:progress |
    1 to: 100 do: [:i |
        Processor sleep: 30.
        progress
            value: i;
            text: i
            displayString, '%'].
    'completed'].
p showModal

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: Centering Progress Dialogs

Jerome Chan
In article <4sv49.6859$SA3.413006@wards>,
 "Ian Bartholomew" <[hidden email]> wrote:

> Jerome,
>
> > Anyone with a workaround?
>
> ProgressDialog (like all Dialog Views) has an aspect called
> #isInitiallyCentered which controls the initial position of the Dialog - the
> default for ProgressDialog is true so the Dialog is centered.
>
> Setting this to false (either programmatically or in the ViewComposer) lets
> Windows position the Dialog as it would any newly opened Window. You can
> then set the #position aspect of the Dialog and, I suspect, that you will
> have to do this if you want to centre the Dialog in a specific Shell.
> Something like (this is ProgressDialog>>example1 expanded)
>
> s := Shell show.
> p := ProgressDialog create.
> p ownerView: s view.
> p view
>     isInitiallyCentered: false;
>     position: s view rectangle center - (p view extent // 2).
> p operation: [:progress |
>     1 to: 100 do: [:i |
>         Processor sleep: 30.
>         progress
>             value: i;
>             text: i
>             displayString, '%'].
>     'completed'].
> p showModal
>
> Regards
>     Ian

Thanks for the tip!