Commit 8018e39f authored by ColinTree's avatar ColinTree Committed by Evan W. Patton

Enable Escape & Enter for confirm dialog when delete a component

Closes #1038
Fixes #1037 
parent ad9806da
......@@ -39,6 +39,8 @@ import com.google.appinventor.shared.simple.ComponentDatabaseInterface;
import com.google.appinventor.shared.storage.StorageUtil;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
......@@ -46,6 +48,7 @@ import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
......@@ -248,6 +251,20 @@ public abstract class MockComponent extends Composite implements PropertyChangeL
add(contentPanel);
}
@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
super.onPreviewNativeEvent(event);
switch (event.getTypeInt()) {
case Event.ONKEYDOWN:
if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) {
hide();
} else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
hide();
MockComponent.this.delete();
}
break;
}
}
}
// Component database: information about components (including their properties and events)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment