mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-27 04:30:22 -04:00
Track touch vs mouse origins of field interactions
This commit is contained in:
parent
a9a9502543
commit
3ce3863ab6
4 changed files with 12 additions and 8 deletions
|
@ -173,6 +173,14 @@ Blockly.Field.prototype.argType_ = null;
|
|||
*/
|
||||
Blockly.Field.prototype.validator_ = null;
|
||||
|
||||
/**
|
||||
* Whether to assume user is using a touch device for interactions.
|
||||
* Used to show different UI for touch interactions, e.g.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Field.prototype.useTouchInteraction_ = false;
|
||||
|
||||
/**
|
||||
* Non-breaking space.
|
||||
* @const
|
||||
|
@ -740,6 +748,7 @@ Blockly.Field.prototype.onMouseDown_ = function(e) {
|
|||
if (gesture) {
|
||||
gesture.setStartField(this);
|
||||
}
|
||||
this.useTouchInteraction_ = Blockly.Touch.getTouchIdentifierFromEvent(event) !== 'mouse';
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -168,10 +168,8 @@ Blockly.FieldAngle.prototype.dispose_ = function() {
|
|||
* @private
|
||||
*/
|
||||
Blockly.FieldAngle.prototype.showEditor_ = function() {
|
||||
var noFocus =
|
||||
goog.userAgent.MOBILE || goog.userAgent.ANDROID || goog.userAgent.IPAD;
|
||||
// Mobile browsers have issues with in-line textareas (focus & keyboards).
|
||||
Blockly.FieldAngle.superClass_.showEditor_.call(this, noFocus);
|
||||
Blockly.FieldAngle.superClass_.showEditor_.call(this, this.useTouchInteraction_);
|
||||
// If there is an existing drop-down someone else owns, hide it immediately and clear it.
|
||||
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||
Blockly.DropDownDiv.clearContent();
|
||||
|
|
|
@ -381,10 +381,8 @@ Blockly.FieldNote.prototype.dispose_ = function() {
|
|||
* @private
|
||||
*/
|
||||
Blockly.FieldNote.prototype.showEditor_ = function() {
|
||||
var noFocus =
|
||||
goog.userAgent.MOBILE || goog.userAgent.ANDROID || goog.userAgent.IPAD;
|
||||
// Mobile browsers have issues with in-line textareas (focus & keyboards).
|
||||
Blockly.FieldNote.superClass_.showEditor_.call(this, noFocus);
|
||||
Blockly.FieldNote.superClass_.showEditor_.call(this, this.useTouchInteraction_);
|
||||
|
||||
// If there is an existing drop-down someone else owns, hide it immediately and clear it.
|
||||
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||
|
|
|
@ -165,8 +165,7 @@ Blockly.FieldNumber.prototype.setConstraints_ = function(opt_min, opt_max,
|
|||
Blockly.FieldNumber.prototype.showEditor_ = function() {
|
||||
Blockly.FieldNumber.activeField_ = this;
|
||||
// Do not focus on mobile devices so we can show the num-pad
|
||||
var showNumPad =
|
||||
goog.userAgent.MOBILE || goog.userAgent.ANDROID || goog.userAgent.IPAD;
|
||||
var showNumPad = this.useTouchInteraction_;
|
||||
Blockly.FieldNumber.superClass_.showEditor_.call(this, false, showNumPad);
|
||||
|
||||
// Show a numeric keypad in the drop-down on touch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue