From 228eebe0a022fac2159c53f504fae8628268b9b9 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sat, 23 Jul 2022 16:44:17 -0500 Subject: [remove] spurious refs to display tree events; [tweak] menu focus I may add these display tree events back in --- examples/13-menus.lisp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'examples') 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))) -- cgit v1.2.3