sciter 打开文件获取路径操作

本文介绍了一种自定义的HTML路径输入控件,通过使用内联块级显示和特定的CSS样式,创建了一个带有下拉按钮的路径输入框。该控件能够显示文件路径,并在点击按钮时触发文件选择对话框。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<html>
    <head>
        <title>Test</title>
        <style>

           input[type=path]
           {
              display:inline-block;
              prototype: PathInput;
              font:system;
              flow:horizontal;
              border:1dip solid threedshadow;
              background: window;
              height:1.8em;
           }

           input[type=path] > caption
           {
              display:block;
              flow:text;
              behavior:edit;
              white-space:pre;
              overflow-x:hidden;
              text-overflow:path-ellipsis;
              line-height:1.8em;
              width:*;
              padding:0 4dip;
           }

           input[type=path] > button {
              display:block;
              style-set:none;
              behavior:clickable;
              width:1em;
              height:*;
              background: url(stock:arrow-down) no-repeat 50% 50%;
           }

           //widget:owns-focus { }

           input#test {
             width:20em;
           }

        </style>
        <script type="text/tiscript">

           class PathInput : Element
           {
              function attached() {  this.update(this.attributes["value"]);  }

              function update(path) {
                this.$content(<caption>{path}</caption><button/>);
              }

              event focusout {
                // reset content to show ellipsis
                this.update(this.value);  
              }

              property value(v) {
                get return this.$(caption).text;
                set this.update(v);
              }

              event click $(button)
              {
                var fn = view.selectFile(#open, "HTML Files (*.htm,*.html)|*.HTM;*.HTML|All Files (*.*)|*.*" , "html" );
                if( fn ) this.update(fn);
              }
           }

        </script>
    </head>
    <body>
        <input|path #test value="" >

    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值