I’m trying to have context menus for manually created components
Date field and Currency field are having cast issues.
DateField dateField = uiComponents.create(DateField.class);
dateField.setStyleName("caption-on-left");
dateField.setCaption(caption);
dateField.unwrap(com.vaadin.ui.DateField.class).addFocusListener(event -> {
loadContextMenu(dateField);
});
field = dateField;
java.lang.ClassCastException: Cannot cast com.haulmont.cuba.web.widgets.CubaCssActionsLayout to com.vaadin.ui.DateField
CurrencyField currencyField = uiComponents.create(CurrencyField.class);
currencyField.setStyleName("caption-on-left");
currencyField.setCaption(caption);
currencyField.unwrap(com.vaadin.ui.TextField.class).addFocusListener(event -> {
loadContextMenu(currencyField);
});
field = currencyField;
Labels,Radio buttons, and checkboxes wont do anything. they don’t have the on focus I tried the contextClick but it does nothing.
Label labelField = uiComponents.create(Label.class);
labelField.unwrap(com.vaadin.ui.Label.class).addContextClickListener(event -> {
loadContextMenu(labelField);
});
labelField.setValue(caption);
field = labelField;
maybe its easier to put the listener on the Hbox that contains the component but havent been sucessful on that either
HBoxLayout layout = uiComponents.create(HBoxLayout.class);
layout.unwrap(com.vaadin.ui.ComponentContainer.class).addListener(event -> {
notifications.create().withCaption("asdasd").show();
templateEditHelper.loadContextMenu(field);
});
Thank you for all the help !!!