Commit 7f77add4 authored by neil.fraser@gmail.com's avatar neil.fraser@gmail.com

Fix touch delay on dropdowns (Issue 247).

git-svn-id: http://blockly.googlecode.com/svn/trunk@1765 c400ca83-b69d-9dd7-9705-49c6b8615e23
parent 901be397
This diff is collapsed.
...@@ -127,7 +127,24 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() { ...@@ -127,7 +127,24 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
menu.addChild(menuItem, true); menu.addChild(menuItem, true);
menuItem.setChecked(value == this.value_); menuItem.setChecked(value == this.value_);
} }
// Listen for mouse/keyboard events.
goog.events.listen(menu, goog.ui.Component.EventType.ACTION, callback); goog.events.listen(menu, goog.ui.Component.EventType.ACTION, callback);
// Listen for touch events (why doesn't Closure handle this already?).
function callbackTouchStart(e) {
var control = this.getOwnerControl(/** @type {Node} */ (e.target));
// Highlight the menu item.
control.handleMouseDown(e);
}
function callbackTouchEnd(e) {
var control = this.getOwnerControl(/** @type {Node} */ (e.target));
// Activate the menu item.
control.performActionInternal(e);
}
menu.getHandler().listen(menu.getElement(), goog.events.EventType.TOUCHSTART,
callbackTouchStart);
menu.getHandler().listen(menu.getElement(), goog.events.EventType.TOUCHEND,
callbackTouchEnd);
// Record windowSize and scrollOffset before adding menu. // Record windowSize and scrollOffset before adding menu.
var windowSize = goog.dom.getViewportSize(); var windowSize = goog.dom.getViewportSize();
var scrollOffset = goog.style.getViewportPageOffset(document); var scrollOffset = goog.style.getViewportPageOffset(document);
......
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