简体   繁体   English

GWT 2.7和GWT Material Design 1.5.3 DatePicker

[英]GWT 2.7 and GWT Material Design 1.5.3 DatePicker

Using MaterialButton, I'm trying to show calendar pane on a screen. 使用MaterialButton,我试图在屏幕上显示日历窗格。 I have code like this: 我有这样的代码:

    @UiField
    MaterialDatePicker editDateCtrl;
    @UiField
    MaterialButton addDateCtrl;

    @UiHandler("addDateCtrl")
    void onClick(ClickEvent ev) {
//      GQuery.console.log(GQuery.$(ev.getSource()).siblings(".input-field"));
//      GQuery.$(ev.getSource()).siblings(".input-field").first().find("input").click();
//      GQuery.$(this.editDateCtrl.getElement());
//      GQuery.$("#gwt-debug-actionBtn").click();
        editDateCtrl.fireEvent(new FocusEvent() {});
    }

I was trying to use focus event, click event and nothing is working. 我试图使用焦点事件,单击事件,但没有任何效果。 Getting an element using plain JavaScript (jQuery) and calling obj.click() / obj.focus() also gives no results. 使用纯JavaScript(jQuery)获取元素并调用obj.click() / obj.focus()也不会产生任何结果。 API of this control does not even contain method show() or something like that (not in version I'm currently using). 此控件的API甚至不包含show()方法或类似的方法(不在我当前使用的版本中)。

I had to use GQuery/JSNI. 我不得不使用GQuery / JSNI。 MaterialDatePicker contains an input element, which has attribute aria-owns valued by id of calendar popup I wanted to show. MaterialDatePicker包含一个输入元素,该元素具有由我要显示的日历弹出窗口的ID值确定的属性aria-owns。 In order to make popup appear, you need add some styles to it. 为了使弹出窗口出现,您需要为其添加一些样式。

Here's code: 这是代码:

String pickerId = GQuery.$(editDateCtrl).find("input").attr("aria-owns");
GQuery.$("#" + pickerId).addClass("picker--focused picker--opened");
GQuery.$("#" + pickerId).attr("aria-hidden", false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM