TextField with InputProm vs ClickShortcut

Hi all,

I’ve done simple thing as following:

  • create a textfield WITH setInputPrompt(“Something”), a button with an event to show the textfield’s value
  • the textfield and the button are added to a panel which adds a clickshortcut (with Enter key only) related to the button’s event

So, the textfield’s value should be displayed correctly if I click the button or press Enter key for any number of times.

BUT, there’s one thing out of control:

  • Tying “Vaadin” (or anything) in the textfield, then PRESS Enter → “Vaadin” is displayed. After that:
  • Clear the textfield, then CLICK the button → “Vaadin” still displayed :frowning:

If I remove the comment at line 27, it works correctly but the textfield lost its focus. And If I remove the setInputPrompt line, everything works well.
I am thinking if I miss something or it’s an issue of Vaadin. Please help!


package com.example.inputtest;

import com.vaadin.Application;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;

public class InputtestApplication extends Application {
	private Button btnInput = null;

	@Override
	public void init() {
		Window mainWindow = new Window("Inputtest Application");
		
		Panel pnlInput = new Panel("Textfield with input prom");
		pnlInput.setSizeFull();
		final TextField txtInput = new TextField("Input: ");
		txtInput.setInputPrompt("enter text here");
		txtInput.setWidth("150px");
		btnInput = new Button("Show Text", new Button.ClickListener()
		{
			
			public void buttonClick(ClickEvent event)
			{
				getMainWindow().showNotification("value: " + txtInput.getValue());
//				btnInput.focus();
			}
		});
		pnlInput.addAction(new Button.ClickShortcut(btnInput, KeyCode.ENTER));
		pnlInput.addComponent(txtInput);
		pnlInput.addComponent(btnInput);
		
		mainWindow.addComponent(pnlInput);
		
		//----------textfield without input prom
		Panel pnlNoInput = new Panel("Textfield WITHOUT input prom");
		pnlNoInput.setSizeFull();
		final TextField txtNoInput = new TextField("Input: ");
		txtNoInput.setWidth("150px");
		Button btnNoInput = new Button("Show Text", new Button.ClickListener()
		{
			
			public void buttonClick(ClickEvent event)
			{
				getMainWindow().showNotification("value: " + txtNoInput.getValue());
			}
		});
		pnlNoInput.addAction(new Button.ClickShortcut(btnNoInput, KeyCode.ENTER));
		pnlNoInput.addComponent(txtNoInput);
		pnlNoInput.addComponent(btnNoInput);
		
		mainWindow.addComponent(pnlNoInput);
		
		setMainWindow(mainWindow);
	}

}

Hi,

This seems to be a defect in Vaadin. I have filed a ticket for the issue:
http://dev.vaadin.com/ticket/8211