Java Code Examples for com.google.gwt.event.dom.client.BlurEvent

The following examples show how to use com.google.gwt.event.dom.client.BlurEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: cuba   Source File: SuggestionsContainer.java    License: Apache License 2.0 6 votes vote down vote up
public SuggestionsContainer(CubaSuggestionFieldWidget suggestionFieldWidget) {
    this.suggestionFieldWidget = suggestionFieldWidget;
    container = DOM.createDiv();

    final Element outer = FocusImpl.getFocusImplForPanel().createFocusable();
    DOM.appendChild(outer, container);
    setElement(outer);

    sinkEvents(Event.ONCLICK
            | Event.ONMOUSEDOWN
            | Event.ONMOUSEOVER
            | Event.ONMOUSEOUT
            | Event.ONFOCUS
            | Event.ONKEYDOWN);

    addDomHandler(event ->
            selectItem(null), BlurEvent.getType());

    setStylePrimaryName(STYLENAME);
}
 
Example 2
Source Project: gwt-material-addins   Source File: MaterialTimePicker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Called after the lolliclock event <code>afterHide</code>.
 */
protected void afterHide() {
    String timeString = getTime();
    Date parsedDate = null;

    if (timeString != null && !timeString.equals("")) {
        try {
            parsedDate = DateTimeFormat.getFormat(options.hour24 ? "HH:mm" : "hh:mm aa").parse(timeString);
        } catch (IllegalArgumentException e) {
            // Silently catch parse errors
        }
    }

    setValue(parsedDate, true);

    // Remove class 'valid' after hide.
    getValidMixin().setOn(false);

    CloseEvent.fire(this, this.time);
    fireEvent(new BlurEvent() {});
}
 
Example 3
private void bindHandlers() {
	if (this.widget == null) {
		return;
	}

	this.registrations.removeHandler();
	switch (this.getTrigger()) {
		case FOCUS:
			this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, FocusEvent.getType()));
			this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, BlurEvent.getType()));
			break;
		case HOVER:
			this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, MouseOverEvent.getType()));
			this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, MouseOutEvent.getType()));
			break;
		case MANUAL:
			break;
		default:
			break;
	}
}
 
Example 4
@Override
public void onBlur(BlurEvent event) {
	this.focused = false;
	if (this.input != null) {
		T val = this.input.flush();
		StyleUtils.toggleStyle(this.container, InputList.STYLE_ERROR, this.hasErrors());
		if (val == null && !this.hasErrors()) {
			InputList.this.removeEditor(this);
		} else {
			this.itemValue = val;
			this.output.edit(val);
		}
	}
	this.resetFocusHandler();
	this.redraw();
}
 
Example 5
Source Project: unitime   Source File: AriaSuggestBox.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONBLUR:
    	BlurEvent.fireNativeEvent(event, this);
    	break;
    case Event.ONFOCUS:
    	FocusEvent.fireNativeEvent(event, this);
    	break;
	}
	super.onBrowserEvent(event);
}
 
Example 6
Source Project: unitime   Source File: TimeSelector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONBLUR:
    	BlurEvent.fireNativeEvent(event, this);
    	break;
    case Event.ONFOCUS:
    	FocusEvent.fireNativeEvent(event, this);
    	break;
	}
	super.onBrowserEvent(event);
}
 
Example 7
public void popup(Widget container, Widget relativeTo) {
	this.setVisible(true);
	StyleUtils.addStyle(this, InputDatePicker.STYLE_POPUP);
	RootPanel.get().add(this);

	Element positioningElement = this.getElement();
	Element relativeElement = relativeTo.getElement();

	int targetHeight = relativeElement.getOffsetHeight();
	int targetTop = relativeElement.getAbsoluteTop();

	int positioningWidth = positioningElement.getOffsetWidth();
	int targetRight = relativeElement.getAbsoluteRight();

	Style elementStyle = positioningElement.getStyle();
	elementStyle.setPosition(Position.ABSOLUTE);
	elementStyle.setLeft(targetRight - positioningWidth, Unit.PX);
	elementStyle.setTop(targetTop + targetHeight, Unit.PX);

	StyleUtils.addStyle(this, InputDatePicker.STYLE_FADE);
	StyleUtils.addStyle(this, InputDatePicker.STYLE_SHOW);

	this.setFocus(true);

	if (this.popupBlurHandler == null) {
		this.popupBlurHandler = this.addBlurHandler(new BlurHandler() {

			@Override
			public void onBlur(BlurEvent event) {
				InputDatePicker.this.hide();
			}
		});
	}
}
 
Example 8
Source Project: appinventor-extensions   Source File: HandlerPanel.java    License: Apache License 2.0 4 votes vote down vote up
public HandlerRegistration addBlurHandler(BlurHandler handler) {
  return addDomHandler(handler, BlurEvent.getType());
}
 
Example 9
@Override
public void onBlur(BlurEvent event) {
	debug("VComboBoxMultiselect: onBlur()");

	if (BrowserInfo.get()
		.isIE() && this.preventNextBlurEventInIE) {
		/*
		 * Clicking in the suggestion popup or on the popup button in IE
		 * causes a blur event to be sent for the field. In other browsers
		 * this is prevented by canceling/preventing default behavior for
		 * the focus event, in IE we handle it here by refocusing the text
		 * field and ignoring the resulting focus event for the textfield
		 * (in onFocus).
		 */
		this.preventNextBlurEventInIE = false;

		Element focusedElement = WidgetUtil.getFocusedElement();
		if (getElement().isOrHasChild(focusedElement) || this.suggestionPopup.getElement()
			.isOrHasChild(focusedElement)) {

			// IF the suggestion popup or another part of the
			// VComboBoxMultiselect
			// was focused, move the focus back to the textfield and prevent
			// the triggered focus event (in onFocus).
			this.iePreventNextFocus = true;
			this.tb.setFocus(true);
			return;
		}
	}

	this.focused = false;
	updatePlaceholder();
	removeStyleDependentName("focus");

	// Send new items when clicking out with the mouse.
	if (!this.readonly) {
		if (this.textInputEnabled && this.allowNewItems && (this.currentSuggestion == null || this.tb.getText()
			.equals(this.currentSuggestion.getReplacementString()))) {
			this.dataReceivedHandler.reactOnInputWhenReady(this.tb.getText());
		} else {
			reset();
		}
		this.suggestionPopup.hide();
	}

	this.connector.sendBlurEvent();
}
 
Example 10
Source Project: cuba   Source File: CubaCheckBoxWidget.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onBlur(BlurEvent arg) {
    removeStyleDependentName("focus");
}
 
Example 11
@Override
public void onBlur(BlurEvent event) {
	debug("VComboBoxMultiselect: onBlur()");

	if (BrowserInfo.get()
		.isIE() && this.preventNextBlurEventInIE) {
		/*
		 * Clicking in the suggestion popup or on the popup button in IE
		 * causes a blur event to be sent for the field. In other browsers
		 * this is prevented by canceling/preventing default behavior for
		 * the focus event, in IE we handle it here by refocusing the text
		 * field and ignoring the resulting focus event for the textfield
		 * (in onFocus).
		 */
		this.preventNextBlurEventInIE = false;

		Element focusedElement = WidgetUtil.getFocusedElement();
		if (getElement().isOrHasChild(focusedElement) || this.suggestionPopup.getElement()
			.isOrHasChild(focusedElement)) {

			// IF the suggestion popup or another part of the
			// VComboBoxMultiselect
			// was focused, move the focus back to the textfield and prevent
			// the triggered focus event (in onFocus).
			this.iePreventNextFocus = true;
			this.tb.setFocus(true);
			return;
		}
	}

	this.focused = false;
	updatePlaceholder();
	removeStyleDependentName("focus");

	// Send new items when clicking out with the mouse.
	if (!this.readonly) {
		if (this.textInputEnabled && this.allowNewItems && (this.currentSuggestion == null || this.tb.getText()
			.equals(this.currentSuggestion.getReplacementString()))) {
			this.dataReceivedHandler.reactOnInputWhenReady(this.tb.getText());
		} else {
			reset();
		}
		this.suggestionPopup.hide();
	}

	this.connector.sendBlurEvent();
}
 
Example 12
Source Project: gwt-material   Source File: MaterialDatePicker.java    License: Apache License 2.0 4 votes vote down vote up
protected void onClose() {
    CloseEvent.fire(this, this);
    fireEvent(new BlurEvent() {});
}
 
Example 13
Source Project: gwt-material-addins   Source File: MaterialRichEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void load() {
    JsRichEditor jsRichEditor = $(getElement());

    options.toolbar = manager.getToolbars();
    options.placeholder = getPlaceholder();
    options.height = getHeight();

    jsRichEditor.materialnote(options);

    // Events
    jsRichEditor.on(RichEditorEvents.MATERIALNOTE_BLUR, event -> {
        fireEvent(new BlurEvent() {
        });
        return true;
    });
    jsRichEditor.on(RichEditorEvents.MATERIALNOTE_FOCUS, event -> {
        fireEvent(new FocusEvent() {
        });
        return true;
    });
    jsRichEditor.on(RichEditorEvents.MATERIALNOTE_KEYUP, event -> {
        fireEvent(new KeyUpEvent() {
        });
        return true;
    });
    jsRichEditor.on(RichEditorEvents.MATERIALNOTE_KEYDOWN, event -> {
        fireEvent(new KeyDownEvent() {
        });
        return true;
    });
    jsRichEditor.on(RichEditorEvents.MATERIALNOTE_PASTE, event -> {
        fireEvent(new PasteEvent(getValue()) {
        });
        return true;
    });
    jsRichEditor.on(RichEditorEvents.MATERIALNOTE_CHANGE, event -> {
        ValueChangeEvent.fire(MaterialRichEditor.this, getHTMLCode(getElement()));
        return true;
    });

    checkContainer();
    AddinsDarkThemeReloader.get().reload(MaterialRichEditorDarkTheme.class);
}
 
Example 14
Source Project: unitime   Source File: AriaSuggestBox.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addBlurHandler(BlurHandler handler) {
	return addHandler(handler, BlurEvent.getType());
}
 
Example 15
Source Project: unitime   Source File: ImageButton.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addBlurHandler(BlurHandler handler) {
	return addDomHandler(handler, BlurEvent.getType());
}
 
Example 16
Source Project: unitime   Source File: TimeSelector.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addBlurHandler(BlurHandler handler) {
	return addHandler(handler, BlurEvent.getType());
}
 
Example 17
Source Project: gwt-traction   Source File: UTCTimeBoxImplHtml4.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onBlur(BlurEvent event) {
    validate();
}
 
Example 18
public void redraw() {
	this.button.setIconType(IconFont.ICON_FILTER);
	this.button.setActive(this.activate);

	Container row = (Container) ((Widget) this.headerCell).getParent();

	this.headerCell.clear();
	if (this.valueChangeRegistration != null) {
		this.valueChangeRegistration.removeHandler();
		this.valueChangeRegistration = null;
	}
	boolean showFilterRow = false;
	if (this.activate) {
		this.headerCell.append(this.inputText);
		this.valueChangeRegistration = this.inputText.addBlurHandler(new BlurHandler() {
			@Override
			public void onBlur(BlurEvent event) {
				String newValue = TableFilter.this.inputText.flush();
				if (!Objects.equal(TableFilter.this.filterValue, newValue)) {
					TableFilter.this.filterValue = newValue;
					TableFilter.this.getDriver().resetDisplay();
				}
			}
		});

		Widget hCell = this.button.getParent().getParent();
		hCell.getElement().getStyle().setWidth(hCell.getOffsetWidth(), Unit.PX);

		showFilterRow = true;
	}
	if (!showFilterRow) {
		for (Widget cell : row) {
			if (cell instanceof TableTH) {
				showFilterRow |= Iterators.size(((TableTH<?>) cell).iterator()) > 0;
				if (showFilterRow) {
					break;
				}
			}
		}
	}
	row.setVisible(showFilterRow);
}
 
Example 19
@Override
public void onBlur(BlurEvent event) {
	if (AbstractHover.this.visibilityChange == Visibility.SHOW) {
		AbstractHover.this.schedule(AbstractHover.this.getHideDelay(), Visibility.HIDE);
	}
}
 
Example 20
@Override
public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(BlurHandler handler) {
	return this.addDomHandler(handler, BlurEvent.getType());
}
 
Example 21
@Override
public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(BlurHandler handler) {
	return this.handlerManager.addHandler(BlurEvent.getType(), handler);
}
 
Example 22
@Override
public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(BlurHandler handler) {
	return this.addDomHandler(handler, BlurEvent.getType());
}
 
Example 23
@Override
public HandlerRegistration addBlurHandler(BlurHandler handler) {
	return this.addDomHandler(handler, BlurEvent.getType());
}
 
Example 24
@Override
public void onBlur(BlurEvent event) {
	for (TokenHelper helper : this.helpers) {
		helper.cancel();
	}
}
 
Example 25
@Override
public HandlerRegistration addBlurHandler(BlurHandler handler) {
	return this.addDomHandler(handler, BlurEvent.getType());
}
 
Example 26
@Override
public void onBlur(BlurEvent event) {
	this.hideInput();
}
 
Example 27
Source Project: gwt-traction   Source File: Viewport.java    License: Apache License 2.0 2 votes vote down vote up
/**
    * Adds a {@link BlurEvent} handler.
    * 
    * @param handler the handler
    * @return returns the handler registration
    */
   @Override
   public HandlerRegistration addBlurHandler(BlurHandler handler) {
return ensureHandlers().addHandler(BlurEvent.getType(), handler);
   }