]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.tables: change hook>> to be called on all row-actions.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 May 2020 16:58:07 +0000 (09:58 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 May 2020 16:59:42 +0000 (09:59 -0700)
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
basis/ui/gadgets/tables/tables.factor
basis/ui/tools/listener/completion/completion.factor

index 2933c61864ad42302cf435221c7eebc72b224860..81ba6fcabf0a030c9f0a7cd374c127ea8f1c545c 100644 (file)
@@ -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
index 0dc5ba0db52a103601cc588bd9978fab8ea7c07d..32cf0fd1eb6ddfb5d787b82b4d1f76a0bbae4d86 100644 (file)
@@ -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 ;
index f8dee124bb1dc08c3ba4886d12ed965b10791a0c..6f7bb8420c25a3e9d2381b664a8d3f548b788532 100644 (file)
@@ -145,8 +145,7 @@ GENERIC#: accept-completion-hook 1 ( item popup -- )
     find-completion-popup
     [ insert-completion ]
     [ accept-completion-hook ]
-    [ nip hide-glass ]
-    2tri ;
+    2bi ;
 
 : <completion-table> ( 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-scroller> ( completion-popup -- scroller )
     table>> <scroller> 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? [