mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
demo waiting for response
This commit is contained in:
parent
59698297c5
commit
9bf04093e1
9 changed files with 76 additions and 24 deletions
34
tutorial/23-tutorial.lisp
Normal file
34
tutorial/23-tutorial.lisp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
(defpackage #:clog-user
|
||||
(:use #:cl #:clog #:clog-gui)
|
||||
(:export start-tutorial))
|
||||
|
||||
(in-package :clog-user)
|
||||
|
||||
;; This is a simple demo using semaphores to wait for user input
|
||||
(defun ask (obj)
|
||||
(let ((result nil)
|
||||
(hold (bordeaux-threads:make-semaphore))
|
||||
(q-box (create-div obj)))
|
||||
(set-on-click (create-button q-box :content "Yes")
|
||||
(lambda (obj)
|
||||
(setf result :yes)
|
||||
(bordeaux-threads:signal-semaphore hold)))
|
||||
(set-on-click (create-button q-box :content "No")
|
||||
(lambda (obj)
|
||||
(setf result :no)
|
||||
(bordeaux-threads:signal-semaphore hold)))
|
||||
(bordeaux-threads:wait-on-semaphore hold :timeout 10)
|
||||
(destroy q-box)
|
||||
result))
|
||||
|
||||
(defun on-new-window (body)
|
||||
(set-on-click (create-button body :content
|
||||
"Click for my question. You have 10 seconds to answer.")
|
||||
(lambda (obj)
|
||||
(create-div body :content (ask body))))
|
||||
(run body))
|
||||
|
||||
(defun start-tutorial ()
|
||||
"Start turtorial."
|
||||
(initialize #'on-new-window)
|
||||
(open-browser))
|
||||
|
|
@ -55,3 +55,4 @@ Tutorial Summary
|
|||
- 20-tutorial.lisp - New CLOG plugin from JavaScript component
|
||||
- 21-tutorial.lisp - New CLOG plugin in Common-Lisp
|
||||
- 22-tutorial.lisp - CLOG GUI Menus and Desktop Look and Feel
|
||||
- 23-tutorial.lisp - Using semaphores to wait for input
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue