how to close modal window by code

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

how to close modal window by code

Petr Fischer
Hello,

in some situation, in the Windows app developed in VAST, I need to find active modal window and close it programmatically.

I tried (in the Workspace) to find AbtShellWindow instance with modal flag and close it in about 3 ways, but without success.

Any ideas? Some "one liner"? :) Thanks! pf

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to close modal window by code

Louis LaBrunda
Hi Petr,

Can you tell us more about what you are trying to do.  When you instantiate a window you can save the instance in a variable and then send it a close message when you want to close it.  If you can't keep the instance (which is the best thing to do) I think you can find a handle to it on windows and come up with some way to close it.  I don't like that much but it is what it is.

Now if you have the instance and the window won't close, what message are you using to close the window?  Are you sure the code to close the window is running?  It could be that whatever modal flag you are using doesn't allow the other code to run.

Lou

On Monday, February 12, 2018 at 9:12:37 PM UTC-5, Petr Fischer wrote:
Hello,

in some situation, in the Windows app developed in VAST, I need to find active modal window and close it programmatically.

I tried (in the Workspace) to find AbtShellWindow instance with modal flag and close it in about 3 ways, but without success.

Any ideas? Some "one liner"? :) Thanks! pf

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to close modal window by code

Petr Fischer
We have "auto logout and quit after inactivity timeout" feature in Windows VAST app, but this functionality is blocked, when some modal window is opened.
There are dozens of modal windows at various places in our app.

So I am finding something like:
(AbtShellWindow select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

When I run our app directly from VAST, I can run some code from Workspace, so running code is not blocked, but it looks like some "events" are blocked.

pf


> Hi Petr,
>
> Can you tell us more about what you are trying to do.  When you instantiate
> a window you can save the instance in a variable and then send it a close
> message when you want to close it.  If you can't keep the instance (which
> is the best thing to do) I think you can find a handle to it on windows and
> come up with some way to close it.  I don't like that much but it is what
> it is.
>
> Now if you have the instance and the window won't close, what message are
> you using to close the window?  Are you sure the code to close the window
> is running?  It could be that whatever modal flag you are using doesn't
> allow the other code to run.
>
> Lou
>
> On Monday, February 12, 2018 at 9:12:37 PM UTC-5, Petr Fischer wrote:
> >
> > Hello,
> >
> > in some situation, in the Windows app developed in VAST, I need to find
> > active modal window and close it programmatically.
> >
> > I tried (in the Workspace) to find AbtShellWindow instance with modal flag
> > and close it in about 3 ways, but without success.
> >
> > Any ideas? Some "one liner"? :) Thanks! pf
> >
>
> --
> You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/va-smalltalk.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to close modal window by code

Petr Fischer
> We have "auto logout and quit after inactivity timeout" feature in Windows VAST app, but this functionality is blocked, when some modal window is opened.
> There are dozens of modal windows at various places in our app.
>
> So I am finding something like:
> (AbtShellWindow select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

Sorry:
(AbtShellWindow allInstances select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

>
> When I run our app directly from VAST, I can run some code from Workspace, so running code is not blocked, but it looks like some "events" are blocked.
>
> pf
>
>
> > Hi Petr,
> >
> > Can you tell us more about what you are trying to do.  When you instantiate
> > a window you can save the instance in a variable and then send it a close
> > message when you want to close it.  If you can't keep the instance (which
> > is the best thing to do) I think you can find a handle to it on windows and
> > come up with some way to close it.  I don't like that much but it is what
> > it is.
> >
> > Now if you have the instance and the window won't close, what message are
> > you using to close the window?  Are you sure the code to close the window
> > is running?  It could be that whatever modal flag you are using doesn't
> > allow the other code to run.
> >
> > Lou
> >
> > On Monday, February 12, 2018 at 9:12:37 PM UTC-5, Petr Fischer wrote:
> > >
> > > Hello,
> > >
> > > in some situation, in the Windows app developed in VAST, I need to find
> > > active modal window and close it programmatically.
> > >
> > > I tried (in the Workspace) to find AbtShellWindow instance with modal flag
> > > and close it in about 3 ways, but without success.
> > >
> > > Any ideas? Some "one liner"? :) Thanks! pf
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> > To post to this group, send email to [hidden email].
> > Visit this group at https://groups.google.com/group/va-smalltalk.
> > For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to close modal window by code

Louis LaBrunda
Hi Petr,

Can you post the exact code you use to open the window and try to close it.  I would like to run your code and see what happens.  If I have to guess at what code you use, what I see may not match what you see.

Also, have you tried #closeWidget?

Lou

On Tuesday, February 13, 2018 at 3:12:29 PM UTC-5, Petr Fischer wrote:
> We have "auto logout and quit after inactivity timeout" feature in Windows VAST app, but this functionality is blocked, when some modal window is opened.
> There are dozens of modal windows at various places in our app.
>
> So I am finding something like:
> (AbtShellWindow select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

Sorry:
(AbtShellWindow allInstances select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

>
> When I run our app directly from VAST, I can run some code from Workspace, so running code is not blocked, but it looks like some "events" are blocked.
>
> pf
>
>
> > Hi Petr,
> >
> > Can you tell us more about what you are trying to do.  When you instantiate
> > a window you can save the instance in a variable and then send it a close
> > message when you want to close it.  If you can't keep the instance (which
> > is the best thing to do) I think you can find a handle to it on windows and
> > come up with some way to close it.  I don't like that much but it is what
> > it is.
> >
> > Now if you have the instance and the window won't close, what message are
> > you using to close the window?  Are you sure the code to close the window
> > is running?  It could be that whatever modal flag you are using doesn't
> > allow the other code to run.
> >
> > Lou
> >
> > On Monday, February 12, 2018 at 9:12:37 PM UTC-5, Petr Fischer wrote:
> > >
> > > Hello,
> > >
> > > in some situation, in the Windows app developed in VAST, I need to find
> > > active modal window and close it programmatically.
> > >
> > > I tried (in the Workspace) to find AbtShellWindow instance with modal flag
> > > and close it in about 3 ways, but without success.
> > >
> > > Any ideas? Some "one liner"? :) Thanks! pf
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="OATMk6-kCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">va-smalltalk...@googlegroups.com.
> > To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="OATMk6-kCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">va-sma...@....
> > Visit this group at <a href="https://groups.google.com/group/va-smalltalk" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/va-smalltalk&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/va-smalltalk&#39;;return true;">https://groups.google.com/group/va-smalltalk.
> > For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: how to close modal window by code - progress: 50%

Petr Fischer
I found a piece of code, that can close the modal shell window.

(OSShell allInstances select: [ :w | w isDestroyed not & w isPrimaryModal ]) do: [ :w | w sendEvent: OSxClose ].

sendEvent: method sends native WinAPI CLOSE event IMHO.
(I remembered that I knew something like WinAPI 15 years ago)

But there's a worse thing:

Our app is waiting for the inactivity timeout as follows (briefly):

 [
      ...
        (Delay forSeconds: timeout) wait.
        (lastActivityTime <= AbtTimestamp now - timeout) ifTrue: [
              OSShell closeAllModalShells.
              <quit app>
        ]
] newProcess resume....

It runs as forked block in a new process.

An example of a modal window is, for example: CwTextPrompter, and in his method "prompt" is this code:

....
    [shell isDestroyed] whileFalse: [
        OSWidget readAndDispatch ifFalse: [ OSWidget wait ]].
....
This loop is rather blocking or not? It looks like even "Delay wait for timeout" in another process (look above) is not running due to "OSWidget wait", right?

There is also "OSEventManager timeOut: xxx" method, should I use it + change "prompt" code to something like this:

    [shell isDestroyed] whileFalse: [
        OSWidget readAndDispatch ifFalse: [ OSWidget wait. Procesor yield. ]].

? Is it helpfull? Also there is no way to redefine "prompt" method in Abt system CwTextPrompter class, but I can deal with it...

pf


Hi Petr,

Can you post the exact code you use to open the window and try to close it.  I would like to run your code and see what happens.  If I have to guess at what code you use, what I see may not match what you see.

Also, have you tried #closeWidget?

Lou

On Tuesday, February 13, 2018 at 3:12:29 PM UTC-5, Petr Fischer wrote:
> We have "auto logout and quit after inactivity timeout" feature in Windows VAST app, but this functionality is blocked, when some modal window is opened.
> There are dozens of modal windows at various places in our app.
>
> So I am finding something like:
> (AbtShellWindow select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

Sorry:
(AbtShellWindow allInstances select: [ :w | <select windows with modal flag only> ]) do: [ :w | w close ].

>
> When I run our app directly from VAST, I can run some code from Workspace, so running code is not blocked, but it looks like some "events" are blocked.
>
> pf
>
>
> > Hi Petr,
> >
> > Can you tell us more about what you are trying to do.  When you instantiate
> > a window you can save the instance in a variable and then send it a close
> > message when you want to close it.  If you can't keep the instance (which
> > is the best thing to do) I think you can find a handle to it on windows and
> > come up with some way to close it.  I don't like that much but it is what
> > it is.
> >
> > Now if you have the instance and the window won't close, what message are
> > you using to close the window?  Are you sure the code to close the window
> > is running?  It could be that whatever modal flag you are using doesn't
> > allow the other code to run.
> >
> > Lou
> >
> > On Monday, February 12, 2018 at 9:12:37 PM UTC-5, Petr Fischer wrote:
> > >
> > > Hello,
> > >
> > > in some situation, in the Windows app developed in VAST, I need to find
> > > active modal window and close it programmatically.
> > >
> > > I tried (in the Workspace) to find AbtShellWindow instance with modal flag
> > > and close it in about 3 ways, but without success.
> > >
> > > Any ideas? Some "one liner"? :) Thanks! pf
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to va-smalltalk...@googlegroups.com.
> > To post to this group, send email to [hidden email].
> > Visit this group at https://groups.google.com/group/va-smalltalk.
> > For more options, visit https://groups.google.com/d/optout.
>


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.