gpt4 book ai didi

java - 文件类型 Vaadin Paper Input 中的文件浏览窗口打开操作会触发哪个事件

转载 作者:太空宇宙 更新时间:2023-11-04 12:12:09 24 4
gpt4 key购买 nike

我想排除文件类型 Vaadin Paper Input 的“选择文件”按钮,并使用标准 Vaadin Paper Input 执行相同的操作即,单击标准 Vaadin Paper Input 时,我希望打开浏览器窗口。

我尝试从标准 Vaadin Paper Input 的点击事件中模拟 File 类型的 Vaadin Paper Input 的点击事件和焦点事件。焦点和单击均按预期正常工作,但浏览器窗口未打开。

我的原型(prototype)代码如下所示,通过这段代码,我能够模拟焦点事件。同样,我尝试了点击事件,但没有达到我的期望。

    final PaperInput text = new PaperInput();
text.setLabel("Text Box");
text.setAlwaysFloatLabel(true);


final PaperInput filePaperInput = new PaperInput();
filePaperInput.setLabel("File");
filePaperInput.setType("file");
filePaperInput.setAlwaysFloatLabel(true);


text.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
filePaperInput.getElement().<InputElement> cast().focus();
}
});

最佳答案

polymer 元素文档如下:

A paper-input can use the native type=search or type=file features. However, since we can't control the native styling of the input (search icon, file button, date placeholder, etc.), in these cases the label will be automatically floated. The placeholder attribute can still be used for additional informational text.

话虽如此,我不确定是否可以将其从容器中取出。

也请阅读此内容:

为什么无法以编程方式触发文件输入选择?

Most browsers prevent submitting files when the input field didn't receive a direct click (or keyboard) event as a security precaution. Some browsers (e.g. Google Chrome) simply prevent the click event, while e.g. Internet Explorer doesn't submit any files that have been selected by a programmatically triggered file input field. Firefox 4 (and later) is so far the only browser with full support for invoking "click"-Events on a completely hidden (display: none) file input field.

关于java - 文件类型 Vaadin Paper Input 中的文件浏览窗口打开操作会触发哪个事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39770578/

24 4 0
文章推荐: linux - 如何使命令的每一行成为另一个命令的参数?
文章推荐: java - 如何获取java类中的Luaj函数参数名称?
文章推荐: linux - 没有ssh的没有密码文件的rsync
文章推荐: javascript - 如何在鼠标进入/离开链接时显示/隐藏非子
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com