All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.vaadin.elements.SubmitButton Maven / Gradle / Ivy

/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.vaadin.elements;


import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.ShortcutRegistration;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;

import java.util.function.Function;

public class SubmitButton extends Button
{
	private ShortcutRegistration enterShortcut;
	
	public SubmitButton(Function messageGetter)
	{
		super(messageGetter.apply("OK"));
		addClassName(CssClassNames.SUBMIT_BUTTON.getName());
		addThemeVariants(ButtonVariant.LUMO_PRIMARY);
		addEnterShortcut();
	}
	
	public void addEnterShortcut()
	{
		enterShortcut = addClickShortcut(Key.ENTER);
	}
	
	public void removeEnterShortcut()
	{
		if (enterShortcut != null)
		{
			enterShortcut.remove();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy