Re: Automatically aborting a dialog
"Alexey Veretennikov (as alexey dot veretennikov at protonmail dot com)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <DxcuCdINz166G_VnU7aEokBLRER69KKo_OILXUqhFMErQCIk3WQSPEQWgTPTnjHCSzPjWbJhc-t2tX1hdL_2nB2zWmIxP5KAeyq62upJozs=@protonmail.com> |
Hi,
Why don't you just save the dialog interface variable and call then capi:apply-in-pane-process ?
(defparameter *dlg* nil)
(let* ((button (make-instance 'capi:push-button :callback (lambda () (capi:exit-dialog t)) :callback-type :none :text "Close"))
(interface (capi:make-container button)))
(setf *dlg* interface))
(capi:display-dialog *dlg*)
And in another thread
(capi:apply-in-pane-process *dlg* #'capi:abort-dialog *dlg*)
BR,
/Alexey
On Tuesday, June 3rd, 2025 at 14:54, Erik Ronström (as erik dot ronstrom at doremir dot com) <[email protected]> wrote:
> Hi,
>
> I have this situation:
>
> - The user requests some resource from the internet.
> - The request may take a long time to finish, and there is no way to tell when or if it will finish.
> - If the request takes very long, after a certain amount of time, I would like to display a dialog saying something like ”This seems to take a long time, do you want to abort or continue waiting?”
> - Now, it may happen that the request finishes while the dialog is on screen. In that case, I would like the dialog to automatically close.
>
> What would be a good way to do this?
>
> I have tried this, which works on Mac:
>
> (progn
> (mp:schedule-timer-relative (mp:make-timer (lambda () (mp:process-send (mp:find-process-from-name "Cocoa Event Loop") #'capi:abort-dialog))) 5)
> (let* ((button (make-instance 'capi:push-button :callback (lambda () (capi:exit-dialog t)) :callback-type :none :text "Close"))
> (interface (capi:make-container button)))
> (capi:display-dialog interface)))
>
>
> The dialog closes after 5 seconds. (It doesn’t work with prompt-for-confirmation, for some reason)
>
>
> My problems with this approach are that
> 1) It feels sketchy to retrieve the process by name. Is it guaranteed to always be called ”Cocoa Event Loop”?
> 2) On non-Mac platforms, how do I even know which process will run the dialog?
>
>
> Erik
>
>
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html