本文整理了Java中com.vaadin.flow.dom.Element.addEventListener()
方法的一些代码示例,展示了Element.addEventListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addEventListener()
方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:addEventListener
[英]Adds an event listener for the given event type.
Event listeners are triggered in the order they are registered.
[中]
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
public DefaultThemableLayoutConfigurator withEventListener(String eventType, DomEventListener listener) {
component.getElement().addEventListener(eventType, listener);
return this;
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
public DefaultComponentConfigurator withEventListener(String eventType, DomEventListener listener) {
component.getElement().addEventListener(eventType, listener);
return this;
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
public DefaultFlexComponentConfigurator<C> withEventListener(String eventType, DomEventListener listener) {
component.getElement().addEventListener(eventType, listener);
return this;
}
代码示例来源:origin: com.vaadin/flow-server
DomListenerRegistration registration = addEventListener(eventType,
listener);
Stream.of(eventDataExpressions).forEach(registration::addEventData);
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
public DefaultComponentConfigurator withEventListener(String eventType, DomEventListener listener, String filter) {
component.getElement().addEventListener(eventType, listener).setFilter(filter);
return this;
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
public DefaultThemableLayoutConfigurator withEventListener(String eventType, DomEventListener listener,
String filter) {
component.getElement().addEventListener(eventType, listener).setFilter(filter);
return this;
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
public DefaultFlexComponentConfigurator<C> withEventListener(String eventType, DomEventListener listener,
String filter) {
component.getElement().addEventListener(eventType, listener).setFilter(filter);
return this;
}
代码示例来源:origin: com.vaadin/vaadin-custom-field-flow
/**
* Constructs a new custom field.
*
* @param defaultValue The initial value for the field. Will also be used by {@link #getEmptyValue()}.
* @see AbstractField#AbstractField(Object)
*/
public CustomField(T defaultValue) {
super(defaultValue);
// Force a value update when the change event generated
getElement().addEventListener("change", e -> this.updateValue());
}
代码示例来源:origin: appreciated/vaadin-app-layout
public void setClickListener(ComponentEventListener<ClickEvent<AppMenuIconItem>> listener) {
getElement().addEventListener("click", domEvent -> listener.onComponentEvent(null));
}
代码示例来源:origin: appreciated/vaadin-app-layout
public void setClickListener(ComponentEventListener<ClickEvent<PaperIconButton>> listener) {
getElement().addEventListener("click", domEvent -> {
if (listener != null) {
listener.onComponentEvent(new ClickEvent<>(this));
}
});
}
代码示例来源:origin: appreciated/vaadin-app-layout
public void setClickListener(ComponentEventListener<ClickEvent<AppMenuIconItem>> listener) {
if (item != null) {
item.setClickListener(listener);
} else {
getElement().addEventListener("click", domEvent -> listener.onComponentEvent(null));
}
}
代码示例来源:origin: appreciated/vaadin-app-layout
public void setNotificationListener(NotificationListener listener) {
this.listener = listener;
if (listener != null && registration == null) {
registration = getElement().addEventListener("click", domEvent -> {
if (listener != null) {
listener.onClick();
}
});
}
addRipple();
}
代码示例来源:origin: com.vaadin/vaadin-context-menu-flow
/**
* Default constructor
*
* @param contextMenu
* the context menu to which this item belongs to
*/
public MenuItemBase(C contextMenu) {
this.contextMenu = contextMenu;
getElement().addEventListener("click", e -> {
if (checkable) {
setChecked(!isChecked());
}
});
}
代码示例来源:origin: com.vaadin/vaadin-confirm-dialog-flow
/**
* Creates an empty dialog with a Confirm button
*/
public ConfirmDialog() {
getElement().addEventListener("opened-changed", event -> {
if (autoAddedToTheUi && !isOpened()) {
getElement().removeFromParent();
autoAddedToTheUi = false;
}
});
}
代码示例来源:origin: com.vaadin/flow-server
/**
* Adds a property change listener and configures the property to be
* synchronized to the server when a given DOM event is fired.
*
* #see {@link #addPropertyChangeListener(String, PropertyChangeListener)}
*
* @param propertyName
* the name of the element property to listen to, not
* <code>null</code>
* @param domEventName
* the name of the DOM event for which the property should be
* synchronized to the server, not <code>null</code>
* @param listener
* the property change listener not add, not <code>null</code>
* @return a handle that can be used for configuring or removing the
* listener
*
* @since
*/
public DomListenerRegistration addPropertyChangeListener(
String propertyName, String domEventName,
PropertyChangeListener listener) {
Registration propertyListenerRegistration = addPropertyChangeListener(
propertyName, listener);
// No-op DOM listener since we're also listening to property changes
return addEventListener(domEventName, NO_OP_DOM_LISTENER)
.synchronizeProperty(propertyName)
.onUnregister(propertyListenerRegistration::remove);
}
代码示例来源:origin: com.vaadin/flow-data
private static <T> void setupTemplateRendererEventHandler(UI ui,
Element eventOrigin, String handlerName, Consumer<T> consumer,
Function<String, T> keyMapper) {
// vaadin.sendEventMessage is an exported function at the client
// side
ui.getPage().executeJavaScript(String.format(
"$0.%s = function(e) {Vaadin.Flow.sendEventMessage(%d, '%s', {key: e.model ? e.model.__data.item.key : e.target.__dataHost.__data.item.key})}",
handlerName, eventOrigin.getNode().getId(), handlerName),
eventOrigin);
DomListenerRegistration registration = eventOrigin.addEventListener(
handlerName, event -> processEventFromTemplateRenderer(event,
handlerName, consumer, keyMapper));
eventOrigin.addDetachListener(event -> registration.remove());
}
代码示例来源:origin: appreciated/vaadin-app-layout
public AppMenuIconItem() {
setWidth("100%");
setHeight("var(--app-layout-menu-button-height)");
getElement().getStyle().set("line-height", "var(--app-layout-menu-button-height)");
getElement().addEventListener("click", domEvent -> {
if (this.listener != null) {
this.listener.onComponentEvent(new ClickEvent<>(this));
}
});
}
代码示例来源:origin: com.vaadin/vaadin-notification-flow
private void initBaseElementsAndListeners() {
getElement().appendChild(templateElement);
getElement().appendVirtualChild(container);
getElement().addEventListener("opened-changed", event -> {
if (autoAddedToTheUi && !isOpened()) {
getElement().removeFromParent();
autoAddedToTheUi = false;
}
});
}
代码示例来源:origin: com.vaadin/vaadin-context-menu-flow
/**
* Creates an empty context menu.
*/
public ContextMenuBase() {
container = new Element("div");
getElement().appendVirtualChild(container);
// Workaround for: https://github.com/vaadin/flow/issues/3496
getElement().setProperty("opened", false);
// Don't open the overlay immediately with any event, let
// contextMenuConnector.js make a server round-trip first.
setOpenOn("none");
getElement().addEventListener("opened-changed", event -> {
if (autoAddedToTheUi && !isOpened()) {
getElement().removeFromParent();
autoAddedToTheUi = false;
}
});
addAttachListener(event -> resetContent());
}
代码示例来源:origin: com.vaadin/vaadin-context-menu-flow
.addEventListener("vaadin-context-menu-before-open", event -> {
beforeOpen();
target.getElement().callFunction(
内容来源于网络,如有侵权,请联系作者删除!