1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add new focus attribute to $select widget (#7081)

* Add focus attribute to $select widget

This address https://github.com/Jermolene/TiddlyWiki5/issues/7070

* Update SelectWidget.tid

Update the documentation for $select widget to include the new attribute: focus
This commit is contained in:
Mohammad Rahmani 2022-12-03 11:52:21 +03:30 committed by GitHub
parent d03da6085b
commit 45a7eb1c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -42,6 +42,9 @@ SelectWidget.prototype.render = function(parent,nextSibling) {
this.execute(); this.execute();
this.renderChildren(parent,nextSibling); this.renderChildren(parent,nextSibling);
this.setSelectValue(); this.setSelectValue();
if(this.selectFocus == "yes") {
this.getSelectDomNode().focus();
}
$tw.utils.addEventListeners(this.getSelectDomNode(),[ $tw.utils.addEventListeners(this.getSelectDomNode(),[
{name: "change", handlerObject: this, handlerMethod: "handleChangeEvent"} {name: "change", handlerObject: this, handlerMethod: "handleChangeEvent"}
]); ]);
@ -143,6 +146,7 @@ SelectWidget.prototype.execute = function() {
this.selectMultiple = this.getAttribute("multiple", false); this.selectMultiple = this.getAttribute("multiple", false);
this.selectSize = this.getAttribute("size"); this.selectSize = this.getAttribute("size");
this.selectTooltip = this.getAttribute("tooltip"); this.selectTooltip = this.getAttribute("tooltip");
this.selectFocus = this.getAttribute("focus");
// Make the child widgets // Make the child widgets
var selectNode = { var selectNode = {
type: "element", type: "element",

View File

@ -40,6 +40,7 @@ The content of the `<$select>` widget should be one or more HTML `<option>` or `
|multiple |If present, switches to multiple selection mode | |multiple |If present, switches to multiple selection mode |
|size |The number of rows to display in multiple selection mode | |size |The number of rows to display in multiple selection mode |
|actions |A string containing ActionWidgets to be triggered when the key combination is detected | |actions |A string containing ActionWidgets to be triggered when the key combination is detected |
|focus |<<.from-version "5.2.4">> Optional. Set to "yes" to automatically focus the HTML select element after creation |
! Examples ! Examples