diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/13-menus.lisp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/examples/13-menus.lisp b/examples/13-menus.lisp index d1c5668..2c797f3 100644 --- a/examples/13-menus.lisp +++ b/examples/13-menus.lisp @@ -9,11 +9,23 @@ (defclass menus-demo (ww::application) ()) (defclass numbered-image (ww::image) - ((n :initarg :num :reader num))) + ((n :initarg :num :reader num) + (menu :initarg :menu :accessor item-menu))) + +(defmethod ww::add-menu-item :after ((menu ww::menu) (item numbered-image)) + (setf (item-menu item) menu)) (ww:defhandler item-clicked (ww::on-mousedown (img) - (format t "~a was clicked~%" (num img)))) + (ww::remove-menu-item (item-menu img) img))) + +(ww::defhandler indicate-focus + (ww::on-focus (img) + (format t "~a got focus~%" (num img)))) + +(ww::defhandler indicate-blur + (ww::on-blur (img) + (format t "~a lost focus~%" (num img)))) (defmethod ww::boot ((app menus-demo)) (let ((vscroller @@ -27,7 +39,9 @@ :num i :texture (ww:get-asset "Fezghoul.png")) do - (ww::add-handler img #'item-clicked) + (ww:add-handler img #'item-clicked) + (ww:add-handler img #'indicate-blur) + (ww:add-handler img #'indicate-focus) (ww::add-menu-item vscroller img)) (ww:add-unit vscroller) (ww:refocus-on vscroller))) |