From: inivekin Date: Sat, 27 Mar 2021 06:54:31 +0000 (+0800) Subject: Adds keyboard driven link following for the browser X-Git-Tag: 0.99~1657 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=5233edb94ada4192b20dd579d4c36832c7c4bc12 Adds keyboard driven link following for the browser --- diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index c7609dbe06..4ced17e86c 100644 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -11,6 +11,16 @@ IN: ui.gadgets.buttons TUPLE: button < border pressed? selected? quot tooltip ; +SYMBOL: active-buttons +active-buttons [ H{ } ] initialize + +: label-from-button ( button -- str ) + children>> [ label? ] find swap [ text>> ] [ drop "unknown" ] if ; + +M: button graft* dup label-from-button active-buttons get set-at ; + +M: button ungraft* label-from-button active-buttons get delete-at ; + ( model -- table ) + [ keys [ ">" swap 2array ] map ] trivial-renderer [ second ] + dup table>> + active-buttons get '[ second _ at invoke-secondary ] >>action + [ hide-glass ] >>hook + t >>selection-required? + 10 >>min-rows + 10 >>max-rows + 30 >>min-cols + 30 >>max-cols drop + ; + +: ( model title -- gadget ) + [ white-interior ] dip + popup-color links-popup new-wrapper ; + +: show-active-buttons-popup ( browser-gadget model title -- ) + + [ hand-loc get-global point>rect show-glass ] [ request-focus ] bi ; inline + +: com-show-active-buttons ( browser-gadget -- ) + active-buttons get "Active buttons" show-active-buttons-popup ;