]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets: simplify focusable-child
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 26 Aug 2023 04:13:45 +0000 (21:13 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 26 Aug 2023 04:13:45 +0000 (21:13 -0700)
basis/ui/gadgets/gadgets-docs.factor
basis/ui/gadgets/gadgets.factor
basis/ui/gadgets/worlds/worlds.factor
extra/ui/gadgets/lists/lists.factor

index 9a97487635a638e3906c406eb46d0aa64853ed26..daddebcb3a3deca8746d77b2f4f46dfae2f6c2d0 100644 (file)
@@ -171,8 +171,8 @@ HELP: find-parent
 { $description "Outputs the first parent of the gadget, starting from the gadget itself, for which the quotation outputs a true value, or " { $link f } " if the quotation outputs " { $link f } " for every parent." } ;
 
 HELP: focusable-child*
-{ $values { "gadget" gadget } { "child/t" "a " { $link gadget } " or " { $link t } } }
-{ $description "Outputs the child of the gadget which would prefer to receive keyboard focus, or " { $link t } " if the gadget itself should receive focus." }
+{ $values { "gadget" gadget } { "child/f" { $maybe gadget } } }
+{ $description "Outputs the child of the gadget which would prefer to receive keyboard focus, or " { $link f } " if the gadget itself should receive focus." }
 { $examples "For example, if your gadget consists of an editor together with an output area whose contents react to changes in editor contents, then the " { $link focusable-child* } " method for your gadget class should return the editor, so that when the gadget is displayed in a window or passed to " { $link request-focus } ", the editor receives keyboard focus automatically." } ;
 
 HELP: focusable-child
index 7654fcde547a79850d9d3262d9656bdd1400b83c..66b78431d1dc52ae7bd36108a5fae3a5760e95af 100644 (file)
@@ -379,15 +379,12 @@ PRIVATE>
         [ parent>> child? ]
     } cond ;
 
-GENERIC: focusable-child* ( gadget -- child/t )
+GENERIC: focusable-child* ( gadget -- child/f )
 
-M: gadget focusable-child* drop t ;
-
-M: f focusable-child* drop t ;
+M: object focusable-child* drop f ;
 
 : focusable-child ( gadget -- child )
-    dup focusable-child*
-    dup t eq? [ drop ] [ nip focusable-child ] if ;
+    dup focusable-child* [ nip focusable-child ] when* ;
 
 GENERIC: request-focus-on ( child gadget -- )
 
index ae6d507bfc283da308d0c66c0a4dc2b4fc8550d4..2085a7297c716372121eb9be9d4b31383f1beabe 100644 (file)
@@ -156,7 +156,7 @@ M: world layout*
     [ call-next-method ]
     [ dup layers>> [ as-big-as-possible ] with each ] bi ;
 
-M: world focusable-child* children>> [ t ] [ first ] if-empty ;
+M: world focusable-child* children>> ?first ;
 
 M: world children-on nip children>> ;
 
index 9cc87699e2537f8cd2d09d1fd8150ab4f0be6874..68d1b08f83ff2a39e706faaf732c149e7c78b6b5 100644 (file)
@@ -62,8 +62,6 @@ M: list draw-gadget*
         ] when*
     ] with-translation ;
 
-M: list focusable-child* drop t ;
-
 : list-value ( list -- object )
     dup index>> swap control-value ?nth ;