From d0a694a7fe62bcf5eb7418f52e76c2e4a14fd942 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 27 May 2020 09:58:07 -0700 Subject: [PATCH] ui.gadgets.tables: change hook>> to be called on all row-actions. Not just when a selected-row was available and action>> was called. Also, call the hook after the action, not before. --- basis/ui/gadgets/tables/tables-docs.factor | 2 +- basis/ui/gadgets/tables/tables.factor | 7 +++---- .../tools/listener/completion/completion.factor | 15 +++------------ 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/basis/ui/gadgets/tables/tables-docs.factor b/basis/ui/gadgets/tables/tables-docs.factor index 2933c61864..81ba6fcabf 100644 --- a/basis/ui/gadgets/tables/tables-docs.factor +++ b/basis/ui/gadgets/tables/tables-docs.factor @@ -34,7 +34,7 @@ ARTICLE: "ui.gadgets.tables.selection" "Table row selection" } ; ARTICLE: "ui.gadgets.tables.actions" "Table row actions" -"When the user double-clicks on a row, or presses " { $command table "row" row-action } " while a row is selected, optional action and hook quotations are invoked. The action receives the row value and the hook receives the table gadget itself. These quotations are stored in the " { $slot "action" } " and " { $snippet "hook" } " slots of a table, respectively." +"When the user double-clicks on a row, or presses " { $command table "row" row-action } ", optional action and hook quotations are invoked. The action receives the row value (if any was selected) and the hook receives the table gadget itself. These quotations are stored in the " { $slot "action" } " and " { $snippet "hook" } " slots of a table, respectively." $nl "If the " { $slot "single-click?" } " slot is set to a true value, then single-clicking on a row will invoke the row action. The default value is " { $link f } "." $nl diff --git a/basis/ui/gadgets/tables/tables.factor b/basis/ui/gadgets/tables/tables.factor index 0dc5ba0db5..32cf0fd1eb 100644 --- a/basis/ui/gadgets/tables/tables.factor +++ b/basis/ui/gadgets/tables/tables.factor @@ -326,10 +326,9 @@ M: table model-changed PRIVATE> : row-action ( table -- ) - dup selected-row - [ swap [ dup hook>> call( table -- ) ] [ action>> call( value -- ) ] bi ] - [ 2drop ] - if ; + dup selected-row [ + over action>> call( value -- ) + ] [ drop ] if dup hook>> call( table -- ) ; : row-action? ( table -- ? ) single-click?>> hand-click# get 2 = or ; diff --git a/basis/ui/tools/listener/completion/completion.factor b/basis/ui/tools/listener/completion/completion.factor index f8dee124bb..6f7bb8420c 100644 --- a/basis/ui/tools/listener/completion/completion.factor +++ b/basis/ui/tools/listener/completion/completion.factor @@ -145,8 +145,7 @@ GENERIC#: accept-completion-hook 1 ( item popup -- ) find-completion-popup [ insert-completion ] [ accept-completion-hook ] - [ nip hide-glass ] - 2tri ; + 2bi ; : ( interactor completion-mode -- table ) [ completion-element ] [ completion-quot ] [ nip ] 2tri @@ -157,7 +156,8 @@ GENERIC#: accept-completion-hook 1 ( item popup -- ) 30 >>min-cols 10 >>min-rows 10 >>max-rows - dup '[ _ accept-completion ] >>action ; + dup '[ _ accept-completion ] >>action + [ hide-glass ] >>hook ; : ( completion-popup -- scroller ) table>> white-interior ; @@ -189,15 +189,6 @@ completion-popup H{ : recall-next ( interactor -- ) history>> history-recall-next ; -: completion-gesture ( gesture completion -- value/f operation/f ) - table>> selected-row - [ [ nip ] [ gesture>operation ] 2bi ] [ drop f ] if ; - -M: completion-popup handle-gesture ( gesture completion -- ? ) - 2dup completion-gesture [ - [ nip hide-glass ] [ invoke-command ] 2bi* f - ] [ drop call-next-method ] if* ; - : ?check-popup ( interactor -- interactor ) dup popup>> [ gadget-child dup completion-popup? [