aboutsummaryrefslogtreecommitdiffhomepage
path: root/gui/menus.lisp
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-07-23 13:49:09 -0500
committerColin Okay <okay@toyful.space>2022-07-23 13:49:09 -0500
commitc82d6751e9414d5c17aca7f8a1138086bd4f9c1d (patch)
treef97f622425d5acfb33386ec37628ecb8bc064c25 /gui/menus.lisp
parent56b362557e5a5f8c1450058fc9e0ef4891473821 (diff)
[add] menu-specific option focus support
Diffstat (limited to 'gui/menus.lisp')
-rw-r--r--gui/menus.lisp16
1 files changed, 16 insertions, 0 deletions
diff --git a/gui/menus.lisp b/gui/menus.lisp
index 2bc5c22..f758d51 100644
--- a/gui/menus.lisp
+++ b/gui/menus.lisp
@@ -5,6 +5,8 @@
(defclass/std menu (unit interactive)
((options :with :std nil
:doc "A list of interactive units")
+ (focus :with :std nil
+ :doc "The option that is focused in this menu, if any.")
(region :std (error "Menus require an explicit region"))))
(defmethod initialize-instance :after ((menu menu) &key)
@@ -14,6 +16,20 @@
(x menu) (region-left region)
(y menu) (region-bottom region))))
+(defmethod (setf closer-mop:slot-value-using-class) :before
+ (new-value class (menu menu) slot)
+ (case (closer-mop:slot-definition-name slot)
+ (focus
+ (when (slot-boundp menu 'focus)
+ (unless (eq new-value (slot-value menu 'focus))
+ (fire-blur-event-on (slot-value menu 'focus)))))))
+
+(defmethod (setf closer-mop:slot-value-using-class ) :after
+ (new-value class (menu menu) slot)
+ (case (closer-mop:slot-definition-name slot)
+ (focus
+ (fire-focus-event-on new-value))))
+
(macrolet
((def-menu-accessors (&rest accessor-names)
(let ((defs