Skip to content

Commit

Permalink
Question standard dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mmontone committed Dec 3, 2013
1 parent f861deb commit 5cf558f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/events.lisp
Expand Up @@ -132,6 +132,25 @@
,features
,@args))

(defun ask (question &key (name "Question")
on-accept
on-cancel)
(with-open-dialog (name
'(:modal "yes"
:resizable "no"))
(<:dialog
(<:id= "question")
(<:title= name)
(<:buttons= "accept, cancel")
(<:ondialogaccept= on-accept)
(<:ondialogcancel= on-cancel)
(<:hbox (<:flex= 1)
(<:hbox (<:align= :center)
(<:flex= 1)
(<:image (src= (asdf:system-relative-pathname :cl-xul "resources/icons/dialog-question-2.png"))))
(<:hbox (<:flex= 1) (<:align= :center)
(<:description question))))))

(defun open-window (window &optional features &rest args)
(let ((window-element (with-xul (funcall window))))
(flet ((serialize-features (features)
Expand Down
3 changes: 2 additions & 1 deletion src/package.lisp
Expand Up @@ -23,7 +23,8 @@
#:open-window
#:with-open-window
#:open-dialog
#:with-open-dialog))
#:with-open-dialog
#:ask))

(defpackage xul-builder
(:nicknames :<)
Expand Down
8 changes: 5 additions & 3 deletions test/showcase/dialogs.lisp
Expand Up @@ -6,7 +6,7 @@
(<:vbox
(<:button (<:label= "Open dialog")
(<:on-command=
(xul::with-open-dialog
(with-open-dialog
("Dialog test"
'(:modal "yes"
:resizable "no"))
Expand All @@ -20,17 +20,19 @@
(<:description "This is a dialog"))))))
(<:button (<:label= "Open component in dialog")
(<:on-command=
(xul::with-open-dialog ("Component in dialog"
(with-open-dialog ("Component in dialog"
'(:modal "yes"
:resizable "no"))
(<:dialog
(<:id= "componentindialog")
(<:title= "Component in dialog")
(<:buttons= "accept")
(render (make-instance 'my-dialog))))))
(<:button (<:label= "Ask")
(<:on-command= (ask "Are you sure?")))
(<:button (<:label= "Open component in window")
(<:on-command=
(xul::with-open-window ()
(with-open-window ()
(<:window
(<:id= "componentinwindow")
(<:title= "Component in window")
Expand Down

0 comments on commit 5cf558f

Please sign in to comment.