List of usage examples for com.google.gwt.user.client.ui KeyboardListener KEY_ESCAPE
int KEY_ESCAPE
To view the source code for com.google.gwt.user.client.ui KeyboardListener KEY_ESCAPE.
Click Source Link
From source file:ca.upei.ic.timetable.client.FindCourseView.java
License:Apache License
public FindCourseView(FindCourseViewController controller) { controller_ = controller;/*from w ww. ja v a 2 s .c o m*/ // set up the dialog box dialogBox_ = new DialogBox(false, true); // autohide = false, modal = true dialogBox_.setAnimationEnabled(true); dialogBox_.setText("Find Courses..."); // i have a horizontal panel HorizontalPanel filterPanel = new HorizontalPanel(); // i have a level flex table levelTable_ = controller_.getLevelModel().getWidget(); departmentTable_ = controller_.getDepartmentModel().getWidget(); semesterTable_ = controller_.getSemesterModel().getWidget(); startTimeWidget_ = controller_.getStartTimeModel().getWidget(); // button panel HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT); // i have an OK button final Button okButton = new Button("Search"); okButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { // search and close the dialog controller_.search(); hide(); } }); okButton.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ENTER) { okButton.click(); } } }); final Button cancelButton = new Button("Cancel"); cancelButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { hide(); } }); cancelButton.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ESCAPE) cancelButton.click(); } }); SimplePanel empty = new SimplePanel(); empty.setWidth("230px"); buttonPanel.add(empty); buttonPanel.add(cancelButton); buttonPanel.add(okButton); buttonPanel.setSpacing(5); buttonPanel.setWidth("485px"); // add the panel to the dialog box dialogBox_.add(PanelUtils.verticalPanel(PanelUtils.horizontalPanel( PanelUtils.verticalPanel(PanelUtils.scrollPanel(levelTable_, 250, 180), PanelUtils.scrollPanel(semesterTable_, 250, 120), PanelUtils.scrollPanel(startTimeWidget_, 250, 30)), PanelUtils.scrollPanel(departmentTable_, 250, 320)), buttonPanel)); dialogBox_.setPopupPosition(240, 0); }
From source file:ca.upei.ic.timetable.client.MessageView.java
License:Apache License
public MessageView(MessageViewController controller) { controller_ = controller;// w ww .j ava2 s . c o m dialogBox_ = new DialogBox(true, true); dialogBox_.setText("Messages"); dialogBox_.setAnimationEnabled(true); dialogBox_.hide(); // XXX a hack to make sure the dialog display top most dialogBox_.getElement().getStyle().setProperty("z-index", "100"); ScrollPanel scrolled = new ScrollPanel(); scrolled.setPixelSize(350, 250); panel_ = new VerticalPanel(); panel_.setWidth("232px"); scrolled.add(panel_); Button closeButton = new Button("Close"); closeButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox_.hide(); } }); closeButton.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ESCAPE) dialogBox_.hide(); } public void onKeyUp(Widget sender, char keyCode, int modifiers) { } }); Button clearButton = new Button("Clear"); clearButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { clearMessage(); } }); dialogBox_.setWidget( PanelUtils.verticalPanel(scrolled, PanelUtils.horizontalPanel(closeButton, clearButton))); }
From source file:ch.heftix.mailxel.client.OrgTextArea.java
License:Open Source License
public OrgTextArea() { KeyboardListener kl = new KeyboardListener() { Duration sinceEscapePressed = null; public void onKeyDown(Widget sender, char keyCode, int modifiers) { if (keyCode == KeyboardListener.KEY_ESCAPE) { sinceEscapePressed = new Duration(); }//from w ww .j a v a 2 s . c o m } public void onKeyUp(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { if ('q' == keyCode) { // System.out.println(sinceEscapePressed.elapsedMillis()); if (null != sinceEscapePressed && (sinceEscapePressed.elapsedMillis() < 300)) { // format region TextArea ta = (TextArea) sender; String text = ta.getText(); int pos = ta.getCursorPos(); int len = ta.getSelectionLength(); String replacement = om.prefixSelection(text, "> ", pos, len); ta.setText(replacement); cancelKey(); } } } }; addKeyboardListener(kl); }
From source file:client.template.dialog.ErrorDialog.java
License:Open Source License
@Override public boolean onKeyDownPreview(final char key, final int modifiers) { switch (key) { case KeyboardListener.KEY_ENTER: case KeyboardListener.KEY_ESCAPE: this.hide(); break;//w w w . j a v a 2 s. co m } return true; }
From source file:client.template.dialog.LoginDialog.java
License:Open Source License
@Override public boolean onKeyDownPreview(final char key, final int modifiers) { switch (key) { case KeyboardListener.KEY_ENTER: this.logIn(); break;// w ww . j a v a 2 s . com case KeyboardListener.KEY_ESCAPE: this.hide(); break; } return true; }
From source file:com.audata.client.widgets.NumericTextBox.java
License:Open Source License
public void onKeyDown(Widget sender, char keyCode, int modifiers) { String newChar = Character.toString(keyCode); switch (keyCode) { case (KeyboardListener.KEY_BACKSPACE): case (KeyboardListener.KEY_DELETE): case (KeyboardListener.KEY_DOWN): case (KeyboardListener.KEY_END): case (KeyboardListener.KEY_ENTER): case (KeyboardListener.KEY_ESCAPE): case (KeyboardListener.KEY_HOME): case (KeyboardListener.KEY_LEFT): case (KeyboardListener.KEY_PAGEUP): case (KeyboardListener.KEY_PAGEDOWN): case (KeyboardListener.KEY_RIGHT): case (KeyboardListener.KEY_SHIFT): case (KeyboardListener.KEY_TAB): case (KeyboardListener.KEY_UP): break;//from ww w. j av a 2s . c o m default: try { new Double(newChar); } catch (NumberFormatException nfe) { this.cancelKey(); } } }
From source file:com.dimdim.conference.ui.common.client.util.CommonModalDialog.java
License:Open Source License
public boolean onEventPreview(Event event) { if (DOM.eventGetType(event) == Event.ONKEYPRESS) { if (event.getKeyCode() == KeyboardListener.KEY_ESCAPE) { onEscapeKey();//from ww w. ja v a 2s .co m } } return super.onEventPreview(event); }
From source file:com.dimdim.conference.ui.envcheck.client.layout.CommonMessagePopup.java
License:Open Source License
public boolean onKeyDownPreview(char key, int modifiers) { // Use the popup's key preview hooks to close the dialog when either // enter or escape is pressed. switch (key) { case KeyboardListener.KEY_ENTER: case KeyboardListener.KEY_ESCAPE: this.closeButton.click(); break;//from www. j a v a2 s . c o m } return true; }
From source file:com.tensegrity.wpalo.client.ui.mvc.cubeview.SaveAsDialog.java
License:Open Source License
private final void addViewNameField(FormPanel panel, FormData data, String initialName) { name.setFieldLabel(constants.subobjectName()); name.setValue(initialName);/*from w ww .ja va2 s .co m*/ name.addKeyListener(new KeyListener() { public void componentKeyUp(ComponentEvent event) { super.componentKeyUp(event); int keyCode = event.getKeyCode(); if (keyCode == KeyboardListener.KEY_ESCAPE) { close(cancelButton); } if (keyCode != KeyboardListener.KEY_ALT && keyCode != KeyboardListener.KEY_CTRL && keyCode != KeyboardListener.KEY_SHIFT && keyCode != KeyboardListener.KEY_LEFT && keyCode != KeyboardListener.KEY_RIGHT && keyCode != KeyboardListener.KEY_DOWN && keyCode != KeyboardListener.KEY_UP && keyCode != KeyboardListener.KEY_HOME && keyCode != KeyboardListener.KEY_END) { name.validate(); } if (pressedEnter(event.getKeyCode())) { close(saveButton); } } }); panel.add(name, data); }
From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusKeyboardListener.java
License:Open Source License
public void onKeyPress(Widget sender, char key, int mods) { if (KeyboardListener.KEY_ENTER == key && enterButton != null) enterButton.click();//ww w. j av a 2 s.com if (KeyboardListener.KEY_ESCAPE == key && escapeButton != null) escapeButton.click(); }