1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-17 15:24:50 +00:00
TiddlyWiki5/core/wiki/macros/keyboard-driven-input.tid
Simon Huber 26ade60e93
Make AdvancedSearch/Filter navigatable by keyboard (#4932)
* Make AdvancedSearch/Filter keyboard-driven

* Adapt keyboard-driven-input macro for use with...

... AdvancedSearch/Filter Tab

* Adjust Filter dropdown for kb-driven AdvancedSearch/Filter

* Adjust Clear Button for kb-driven AdvancedSearch/Filter

* Adjust Delete Button for kb-driven AdvancedSearch/Filter

* Adjust Export Button for kb-driven AdvancedSearch/Filter

* Update clear.tid

* Avoid editing the wron tiddler

* Make cancel-search-actions a bit more sophisticated

* Update Filter.tid

* Update Filter.tid

* Update Filter.tid

* Update keyboard-driven-input.tid

* Update dropdown.tid

* Update dropdown.tid

* Update Filter.tid

* Update clear.tid

* Update delete.tid

* Update dropdown.tid

* Update export.tid

* Update clear.tid

* Update Shadows.tid

* Update Standard.tid

* Update Shadows.tid

* Update System.tid

* Update Filter.tid

* Update keyboard-driven-input.tid
2020-11-01 17:12:29 +00:00

68 lines
3.8 KiB
Plaintext

title: $:/core/macros/keyboard-driven-input
tags: $:/tags/Macro
\define change-input-tab(stateTitle,tag,beforeafter,defaultState,actions)
<$set name="tabsList" filter="[all[shadows+tiddlers]tag<__tag__>!has[draft.of]]">
<$vars currentState={{{ [<__stateTitle__>!is[missing]get[text]] ~[<__defaultState__>] }}} firstTab={{{ [enlist<tabsList>nth[1]] }}} lastTab={{{ [enlist<tabsList>last[]] }}}>
<$set name="nextTab" value={{{ [all[shadows+tiddlers]tag<__tag__>!has[draft.of]$beforeafter$<currentState>] ~[[$beforeafter$]removeprefix[after]suffix[]addprefix<firstTab>] ~[[$beforeafter$]removeprefix[before]suffix[]addprefix<lastTab>] }}}>
<$action-setfield $tiddler=<<__stateTitle__>> text=<<nextTab>>/>
$actions$
</$set>
</$vars>
</$set>
\end
\define keyboard-input-actions()
<$list filter="[<__index__>match[]]">
<$action-setfield $tiddler=<<__storeTitle__>> text={{{ [<__tiddler__>get<__field__>] }}}/>
</$list>
<$list filter="[<__index__>!match[]]">
<$action-setfield $tiddler=<<__storeTitle__>> text={{{ [<__tiddler__>getindex<__index__>] }}}/>
</$list>
\end
\define input-next-actions(afterOrBefore:"after",reverse:"")
<$list filter="[<__storeTitle__>get[text]minlength<__filterMinLength__>] [<__filterMinLength__>match[0]] +[limit[1]]" variable="ignore">
<$vars userInput={{{ [<__storeTitle__>get[text]] }}} selectedItem={{{ [<__selectionStateTitle__>get[text]] }}}>
<$set name="configTiddler" value={{{ [subfilter<__configTiddlerFilter__>] }}}>
<$vars primaryListFilter={{{ [<configTiddler>get<__firstSearchFilterField__>] }}} secondaryListFilter={{{ [<configTiddler>get<__secondSearchFilterField__>] }}}>
<$set name="filteredList" filter="[subfilter<primaryListFilter>addsuffix[-primaryList]] =[subfilter<secondaryListFilter>addsuffix[-secondaryList]]">
<$set name="nextItem" value={{{ [enlist<filteredList>$afterOrBefore$<selectedItem>] ~[enlist<filteredList>$reverse$nth[1]] }}}>
<$list filter="[<nextItem>minlength[1]]" variable="ignore">
<$action-setfield $tiddler=<<__selectionStateTitle__>> text=<<nextItem>>/>
<$list filter="[<__index__>match[]]">
<$action-setfield $tiddler=<<__tiddler__>> $field=<<__field__>> $value={{{ [<nextItem>] +[splitregexp[(?:.(?!-))+$]] }}}/>
</$list>
<$list filter="[<__index__>!match[]]">
<$action-setfield $tiddler=<<__tiddler__>> $index=<<__index__>> $value={{{ [<nextItem>] +[splitregexp[(?:.(?!-))+$]] }}}/>
</$list>
<$action-setfield $tiddler=<<__refreshTitle__>> text="yes"/>
</$list>
</$set>
</$set>
</$vars>
</$set>
</$vars>
</$list>
\end
\define keyboard-driven-input(tiddler,storeTitle,field:"text",index:"",tag:"input",type,focus:"",inputAcceptActions,inputAcceptVariantActions,inputCancelActions,placeholder:"",default:"",class,focusPopup,rows,minHeight,tabindex,size,autoHeight,filterMinLength:"0",refreshTitle,selectionStateTitle,cancelPopups:"",configTiddlerFilter,firstSearchFilterField:"first-search-filter",secondSearchFilterField:"second-search-filter")
\whitespace trim
<$keyboard key="((input-accept))" actions=<<__inputAcceptActions__>>>
<$keyboard key="((input-accept-variant))" actions=<<__inputAcceptVariantActions__>>>
<$keyboard key="((input-up))" actions=<<input-next-actions "before" "reverse[]">>>
<$keyboard key="((input-down))" actions=<<input-next-actions>>>
<$keyboard key="((input-cancel))" actions=<<__inputCancelActions__>>>
<$edit-text tiddler=<<__tiddler__>> field=<<__field__>> index=<<__index__>>
inputActions=<<keyboard-input-actions>> tag=<<__tag__>> class=<<__class__>>
placeholder=<<__placeholder__>> default=<<__default__>> focusPopup=<<__focusPopup__>>
focus=<<__focus__>> type=<<__type__>> rows=<<__rows__>> minHeight=<<__minHeight__>>
tabindex=<<__tabindex__>> size=<<__size__>> autoHeight=<<__autoHeight__>>
refreshTitle=<<__refreshTitle__>> cancelPopups=<<__cancelPopups__>>/>
</$keyboard>
</$keyboard>
</$keyboard>
</$keyboard>
</$keyboard>
\end