Enter ClickShortcut not working in a PopupView

Vaadin 6.4.8

I’m trying to set an Enter click shortcut for a button in a PopupView, but I can’t seem to get it to work. I expanded on the sampler dynamic PopupView example below.

Can anyone spot what I am doing wrong?

In debug mode, I see the action being sent in the UIDL (action key=1 kc=13 mk={}), but as far as I can tell, the action is never triggered. Do PopupViews “eat” the actions for some reason?

package com.example.helloworld;

import com.vaadin.Application;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.PopupView.PopupVisibilityEvent;
import com.vaadin.ui.PopupView.PopupVisibilityListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.PopupView;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.Reindeer;

public class HelloWorldApplication extends Application {
   
   @Override
   public void init() {
      final Window mainWindow = new Window("HelloWorld Application");
      setMainWindow(mainWindow);

      // In this sample we update the minimized view value with the content of
      // the TextField inside the popup.
      PopupTextField ptf = new PopupTextField();
      PopupView popup = new PopupView(ptf);
      ptf.setPopupView(popup);   // tell the content about the popup

      popup.setDescription("Click to edit");
      popup.setHideOnMouseOut(false);
      mainWindow.addComponent(popup);
   }

   // Create a dynamically updating content for the popup
   public class PopupTextField implements PopupView.Content, PopupVisibilityListener, Button.ClickListener {

      private String miniText = "Initial dynamic content";

      private TextField tf = new TextField("Edit me");
      private VerticalLayout root = new VerticalLayout();
      private Button saveButton = new Button("Save");
      private PopupView popupView;

      public PopupTextField() {
         root.setSizeUndefined();
         root.setSpacing(true);
         root.setMargin(true);
         root.addComponent(new Label(
            "The changes made to any components inside the popup are reflected automatically when the popup is closed, but you might want to provide explicit action buttons for the user, like \"Save\" or \"Close\"."));

         root.addComponent(tf);
         tf.setValue(miniText);
         tf.setWidth("300px");

         saveButton.addListener(this);
         saveButton.setStyleName(Reindeer.BUTTON_SMALL);
         root.addComponent(saveButton);
      }

      public String getMinimizedValueAsHTML() {
         return miniText;
      }

      public Component getPopupComponent() {
         return root;
      }

      public void setPopupView(PopupView popupView) {
         this.popupView = popupView;
         popupView.addListener(this);
      }

      public Button getSaveButton() {
         return saveButton;
      }

      @Override
      public void buttonClick(ClickEvent event) {
         miniText = tf.getValue().toString();
         popupView.setPopupVisible(false);
      }

      @Override
      public void popupVisibilityChange(PopupVisibilityEvent event) {
         if (event.isPopupVisible()) {
            
            // Why isn't this working?            
            saveButton.setClickShortcut(KeyCode.ENTER);
         }
      }
   };   
}

Vaadin 6.4.8

I have the same key event issue on PopupView.
Shortcuts work for panel on
Window
. Setting the same panel as
PopupView
content - and shortcuts stop working.

Issue relates to
Button.setClickShortcut()
as well as to
AbstractField.addShortcutListener()
.

Ok, thanks for the confirmation that it’s not just me.

I guess I’ll open a ticket. In the meantime, I’ll try using a subwindow instead of a PopupView.

Charles