aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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