} ;
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
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 ;
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
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 ;
: 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? [