diff options
author | Colin Okay <okay@toyful.space> | 2022-07-23 16:44:17 -0500 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-07-23 16:44:17 -0500 |
commit | 228eebe0a022fac2159c53f504fae8628268b9b9 (patch) | |
tree | 34dbd48f80f8833597adb96ba9073b05354cd286 /examples | |
parent | 8f36ccc37a52557e6b41515e510033a61998ef73 (diff) |
[remove] spurious refs to display tree events; [tweak] menu focus
I may add these display tree events back in
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))) |