<html>
<head>
<title>file name input</title>
<style>
widget[type=folder-name] {
prototype: FolderName;
flow:horizontal;
width:20em;
}
widget[type=file-name] > input { width:*; }
</style>
<script type="text/tiscript">
class FolderName : Behavior {
function attached() {
this.$append( <input|text.path><button.selector>…</button>);
var path = this.path = this.$(.path);
this.$(button.selector) << event click() {
var fn = view.selectFolder(); //只有他
if( fn ) path.value = fn;
(this super).postEvent(Event.EDIT_VALUE_CHANGED);
};
}
property value(v) {
get { return this.path.value; }
set { this.path.value = v; }
}
}
$(widget).onValueChanged = function() {
stdout.println(this.value);
};
</script>
</head>
<body>
Folder name:
<widget|folder-name name=test />
</body>
</html>
本文介绍了一种文件名输入组件的设计方案,通过自定义的HTML和TIScript实现了一个可以手动输入路径或通过选择文件夹来填充路径的界面组件。该组件支持水平布局,宽度固定为20em,并通过点击按钮触发文件夹选择事件。
1400

被折叠的 条评论
为什么被折叠?



