1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 13:29:56 +00:00
TiddlyWiki5/core/wiki/macros/keyboard-driven-input.tid
Simon Huber 0d2df34c58
Keyboard-driven dropdown inputs (#4725)
* Add shortcut descriptions to Misc.multids

* Update framed.js

* Update simple.js

* Add inputActions and refreshTitle to factory.js

* Add inputActions and refreshTitle to edit.js

* Update DefaultSearchResultList.tid

* Update search.tid

* Update ShortcutInfo.multids

* Update shortcuts.multids

* Create keyboard-driven-input.tid

* Update tag-picker.tid

* Create keyboard-driven-input_Macro.tid

* Update EditTextWidget.tid

* Update EditWidget.tid

* Update engine.js

* Update base.tid

* Use primaryListFilter, secondaryListFilter, primaryList and secondaryList

* Update tag-picker.tid

* Update search.tid

* Update DefaultSearchResultList.tid

* Update keyboard-driven-input_Macro.tid

* Fix typo udpate -> update

* Update framed.js
2020-07-13 17:42:55 +01:00

52 lines
2.8 KiB
Plaintext

title: $:/core/macros/keyboard-driven-input
tags: $:/tags/Macro
\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="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]]">
<$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>
</$list>
\end
\define keyboard-driven-input(tiddler,storeTitle,field:"text",index:"",tag:"input",type,focus:"",inputAcceptActions,inputAcceptVariantActions,inputCancelActions,placeholder:"",default:"",class,primaryListFilter,secondaryListFilter,focusPopup,rows,minHeight,tabindex,size,autoHeight,filterMinLength:"0",refreshTitle,selectionStateTitle,cancelPopups:"")
<$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