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.
master
John Benediktsson 2020-05-27 09:58:07 -07:00
parent 75d5a8a8f9
commit d0a694a7fe
3 changed files with 7 additions and 17 deletions

View 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

View 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 ;

View 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? [