com.vaadin.flow.dom.Element.addEventListener()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(315)

本文整理了Java中com.vaadin.flow.dom.Element.addEventListener()方法的一些代码示例,展示了Element.addEventListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addEventListener()方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:addEventListener

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

  1. @Override
  2. public DefaultThemableLayoutConfigurator withEventListener(String eventType, DomEventListener listener) {
  3. component.getElement().addEventListener(eventType, listener);
  4. return this;
  5. }

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. @Override
  2. public DefaultComponentConfigurator withEventListener(String eventType, DomEventListener listener) {
  3. component.getElement().addEventListener(eventType, listener);
  4. return this;
  5. }

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. @Override
  2. public DefaultFlexComponentConfigurator<C> withEventListener(String eventType, DomEventListener listener) {
  3. component.getElement().addEventListener(eventType, listener);
  4. return this;
  5. }

代码示例来源:origin: com.vaadin/flow-server

  1. DomListenerRegistration registration = addEventListener(eventType,
  2. listener);
  3. Stream.of(eventDataExpressions).forEach(registration::addEventData);

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. @Override
  2. public DefaultComponentConfigurator withEventListener(String eventType, DomEventListener listener, String filter) {
  3. component.getElement().addEventListener(eventType, listener).setFilter(filter);
  4. return this;
  5. }

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. @Override
  2. public DefaultThemableLayoutConfigurator withEventListener(String eventType, DomEventListener listener,
  3. String filter) {
  4. component.getElement().addEventListener(eventType, listener).setFilter(filter);
  5. return this;
  6. }

代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow

  1. @Override
  2. public DefaultFlexComponentConfigurator<C> withEventListener(String eventType, DomEventListener listener,
  3. String filter) {
  4. component.getElement().addEventListener(eventType, listener).setFilter(filter);
  5. return this;
  6. }

代码示例来源:origin: com.vaadin/vaadin-custom-field-flow

  1. /**
  2. * Constructs a new custom field.
  3. *
  4. * @param defaultValue The initial value for the field. Will also be used by {@link #getEmptyValue()}.
  5. * @see AbstractField#AbstractField(Object)
  6. */
  7. public CustomField(T defaultValue) {
  8. super(defaultValue);
  9. // Force a value update when the change event generated
  10. getElement().addEventListener("change", e -> this.updateValue());
  11. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public void setClickListener(ComponentEventListener<ClickEvent<AppMenuIconItem>> listener) {
  2. getElement().addEventListener("click", domEvent -> listener.onComponentEvent(null));
  3. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public void setClickListener(ComponentEventListener<ClickEvent<PaperIconButton>> listener) {
  2. getElement().addEventListener("click", domEvent -> {
  3. if (listener != null) {
  4. listener.onComponentEvent(new ClickEvent<>(this));
  5. }
  6. });
  7. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public void setClickListener(ComponentEventListener<ClickEvent<AppMenuIconItem>> listener) {
  2. if (item != null) {
  3. item.setClickListener(listener);
  4. } else {
  5. getElement().addEventListener("click", domEvent -> listener.onComponentEvent(null));
  6. }
  7. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public void setNotificationListener(NotificationListener listener) {
  2. this.listener = listener;
  3. if (listener != null && registration == null) {
  4. registration = getElement().addEventListener("click", domEvent -> {
  5. if (listener != null) {
  6. listener.onClick();
  7. }
  8. });
  9. }
  10. addRipple();
  11. }

代码示例来源:origin: com.vaadin/vaadin-context-menu-flow

  1. /**
  2. * Default constructor
  3. *
  4. * @param contextMenu
  5. * the context menu to which this item belongs to
  6. */
  7. public MenuItemBase(C contextMenu) {
  8. this.contextMenu = contextMenu;
  9. getElement().addEventListener("click", e -> {
  10. if (checkable) {
  11. setChecked(!isChecked());
  12. }
  13. });
  14. }

代码示例来源:origin: com.vaadin/vaadin-confirm-dialog-flow

  1. /**
  2. * Creates an empty dialog with a Confirm button
  3. */
  4. public ConfirmDialog() {
  5. getElement().addEventListener("opened-changed", event -> {
  6. if (autoAddedToTheUi && !isOpened()) {
  7. getElement().removeFromParent();
  8. autoAddedToTheUi = false;
  9. }
  10. });
  11. }

代码示例来源:origin: com.vaadin/flow-server

  1. /**
  2. * Adds a property change listener and configures the property to be
  3. * synchronized to the server when a given DOM event is fired.
  4. *
  5. * #see {@link #addPropertyChangeListener(String, PropertyChangeListener)}
  6. *
  7. * @param propertyName
  8. * the name of the element property to listen to, not
  9. * <code>null</code>
  10. * @param domEventName
  11. * the name of the DOM event for which the property should be
  12. * synchronized to the server, not <code>null</code>
  13. * @param listener
  14. * the property change listener not add, not <code>null</code>
  15. * @return a handle that can be used for configuring or removing the
  16. * listener
  17. *
  18. * @since
  19. */
  20. public DomListenerRegistration addPropertyChangeListener(
  21. String propertyName, String domEventName,
  22. PropertyChangeListener listener) {
  23. Registration propertyListenerRegistration = addPropertyChangeListener(
  24. propertyName, listener);
  25. // No-op DOM listener since we're also listening to property changes
  26. return addEventListener(domEventName, NO_OP_DOM_LISTENER)
  27. .synchronizeProperty(propertyName)
  28. .onUnregister(propertyListenerRegistration::remove);
  29. }

代码示例来源:origin: com.vaadin/flow-data

  1. private static <T> void setupTemplateRendererEventHandler(UI ui,
  2. Element eventOrigin, String handlerName, Consumer<T> consumer,
  3. Function<String, T> keyMapper) {
  4. // vaadin.sendEventMessage is an exported function at the client
  5. // side
  6. ui.getPage().executeJavaScript(String.format(
  7. "$0.%s = function(e) {Vaadin.Flow.sendEventMessage(%d, '%s', {key: e.model ? e.model.__data.item.key : e.target.__dataHost.__data.item.key})}",
  8. handlerName, eventOrigin.getNode().getId(), handlerName),
  9. eventOrigin);
  10. DomListenerRegistration registration = eventOrigin.addEventListener(
  11. handlerName, event -> processEventFromTemplateRenderer(event,
  12. handlerName, consumer, keyMapper));
  13. eventOrigin.addDetachListener(event -> registration.remove());
  14. }

代码示例来源:origin: appreciated/vaadin-app-layout

  1. public AppMenuIconItem() {
  2. setWidth("100%");
  3. setHeight("var(--app-layout-menu-button-height)");
  4. getElement().getStyle().set("line-height", "var(--app-layout-menu-button-height)");
  5. getElement().addEventListener("click", domEvent -> {
  6. if (this.listener != null) {
  7. this.listener.onComponentEvent(new ClickEvent<>(this));
  8. }
  9. });
  10. }

代码示例来源:origin: com.vaadin/vaadin-notification-flow

  1. private void initBaseElementsAndListeners() {
  2. getElement().appendChild(templateElement);
  3. getElement().appendVirtualChild(container);
  4. getElement().addEventListener("opened-changed", event -> {
  5. if (autoAddedToTheUi && !isOpened()) {
  6. getElement().removeFromParent();
  7. autoAddedToTheUi = false;
  8. }
  9. });
  10. }

代码示例来源:origin: com.vaadin/vaadin-context-menu-flow

  1. /**
  2. * Creates an empty context menu.
  3. */
  4. public ContextMenuBase() {
  5. container = new Element("div");
  6. getElement().appendVirtualChild(container);
  7. // Workaround for: https://github.com/vaadin/flow/issues/3496
  8. getElement().setProperty("opened", false);
  9. // Don't open the overlay immediately with any event, let
  10. // contextMenuConnector.js make a server round-trip first.
  11. setOpenOn("none");
  12. getElement().addEventListener("opened-changed", event -> {
  13. if (autoAddedToTheUi && !isOpened()) {
  14. getElement().removeFromParent();
  15. autoAddedToTheUi = false;
  16. }
  17. });
  18. addAttachListener(event -> resetContent());
  19. }

代码示例来源:origin: com.vaadin/vaadin-context-menu-flow

  1. .addEventListener("vaadin-context-menu-before-open", event -> {
  2. beforeOpen();
  3. target.getElement().callFunction(

相关文章