diff options
author | Denis Anisimov <denis@vaadin.com> | 2016-10-30 18:11:21 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-10-31 14:45:13 +0000 |
commit | 287614dbabc4ec8f2e72f56067312ad47ce46f5d (patch) | |
tree | 2f4811c2de5dd2aa4cf10b3a50b6ac484764f866 /server | |
parent | ee47a94e17aadae18fbee6ad804e35ab12446df5 (diff) | |
download | vaadin-framework-287614dbabc4ec8f2e72f56067312ad47ce46f5d.tar.gz vaadin-framework-287614dbabc4ec8f2e72f56067312ad47ce46f5d.zip |
Implement focus/blur events for RadioButtonGroup.
Fixes vaadin/framework8-issues#333
Change-Id: I55f5d6a0cd690f2c0b5e757318a5f528a67ef34e
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/RadioButtonGroup.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java index a1474c91d4..6f1191e8d4 100644 --- a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java +++ b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java @@ -20,11 +20,19 @@ import java.util.Collection; import java.util.Objects; import com.vaadin.data.Listing; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.BlurNotifier; +import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcDecorator; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.server.Resource; import com.vaadin.server.ResourceReference; import com.vaadin.server.SerializablePredicate; import com.vaadin.server.data.DataGenerator; import com.vaadin.server.data.DataSource; +import com.vaadin.shared.Registration; import com.vaadin.shared.ui.ListingJsonConstants; import com.vaadin.shared.ui.optiongroup.RadioButtonGroupState; @@ -39,7 +47,8 @@ import elemental.json.JsonObject; * @author Vaadin Ltd * @since 8.0 */ -public class RadioButtonGroup<T> extends AbstractSingleSelect<T> { +public class RadioButtonGroup<T> extends AbstractSingleSelect<T> + implements FocusNotifier, BlurNotifier { private IconGenerator<T> itemIconGenerator = item -> null; @@ -93,6 +102,7 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T> { * @see Listing#setDataSource(DataSource) */ public RadioButtonGroup() { + registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent)); setSelectionModel(new SimpleSingleSelection()); addDataGenerator(new DataGenerator<T>() { @@ -245,4 +255,32 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T> { Objects.requireNonNull(itemEnabledProvider); this.itemEnabledProvider = itemEnabledProvider; } + + @Override + public Registration addFocusListener(FocusListener listener) { + addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, + FocusListener.focusMethod); + return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class, + listener); + } + + @Override + @Deprecated + public void removeFocusListener(FocusListener listener) { + removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + } + + @Override + public Registration addBlurListener(BlurListener listener) { + addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, + BlurListener.blurMethod); + return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class, + listener); + } + + @Override + @Deprecated + public void removeBlurListener(BlurListener listener) { + removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); + } } |