diff --git a/composer/rotation-composer.js b/composer/rotation-composer.js index f9d3ab8a56..e2966735f5 100644 --- a/composer/rotation-composer.js +++ b/composer/rotation-composer.js @@ -54,7 +54,8 @@ exports.RotationComposer = Composer.specialize(/** @lends RotationComposer# */ { value: function RotationComposer() { this.super(); this._translateComposer = new TranslateComposer(); - this._translateComposer.hasMomentum = false; + this.hasMomentum = false; + this._translateComposer.listenToWheelEvent = true; this._translateComposer.hasBouncing = false; } }, diff --git a/test/all.js b/test/all.js index d4983c3908..6a37a11123 100644 --- a/test/all.js +++ b/test/all.js @@ -97,6 +97,7 @@ module.exports = require("montage-testing").run(require, [ {name: "spec/ui/slot-spec", node: false}, {name: "spec/ui/substitution-spec", node: false}, {name: "spec/ui/text-input-spec", node: false}, + {name: "spec/ui/control/text-field-spec", node: false}, {name: "spec/ui/slider-spec", node: false}, {name: "spec/ui/text/text-spec", node: false}, {name: "spec/ui/label/label-spec", node: false}, @@ -129,14 +130,14 @@ module.exports = require("montage-testing").run(require, [ {name: "spec/data/raw-data-type-mapping-spec", node: false}, {name: "spec/data/integration", node: false}, - // Meta - { name: "spec/meta/converter-object-descriptor-spec", node: false}, - { name: "spec/meta/module-object-descriptor-spec", node: false}, - {name: "spec/meta/build-in-component-object-descriptor-spec", node: false}, - {name: "spec/meta/component-object-descriptor-spec", node: false}, - {name: "spec/meta/controller-object-descriptor-spec", node: false}, - {name: "spec/meta/event-descriptor-spec", node: false}, - { name: "spec/meta/object-descriptor-spec", node: false} + // // Meta + // { name: "spec/meta/converter-object-descriptor-spec", node: false}, + // { name: "spec/meta/module-object-descriptor-spec", node: false}, + // {name: "spec/meta/build-in-component-object-descriptor-spec", node: false}, + // {name: "spec/meta/component-object-descriptor-spec", node: false}, + // {name: "spec/meta/controller-object-descriptor-spec", node: false}, + // {name: "spec/meta/event-descriptor-spec", node: false}, + // { name: "spec/meta/object-descriptor-spec", node: false} ]).then(function () { console.log('montage-testing', 'End'); }, function (err) { diff --git a/test/spec/ui/control/text-field-spec.js b/test/spec/ui/control/text-field-spec.js new file mode 100644 index 0000000000..f4d2446435 --- /dev/null +++ b/test/spec/ui/control/text-field-spec.js @@ -0,0 +1,50 @@ +var Montage = require("montage").Montage; +var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; + +TestPageLoader.queueTest("../../../../ui/text-field.info/sample/index", function (testPage) { + describe("text-field.info/test/converter", function () { + var testDocument; + + beforeEach(function () { + testDocument = testPage.iframe.contentDocument; + }); + + describe("selecting the activeTarget", function () { + var eventManager, proximalElement, proximalComponent; + + describe("when interaction starts on a proximal target that accepts focus", function () { + beforeEach(function () { + numberFieldElement = testDocument.querySelector("[data-montage-id=number-field]"); + numberFieldComponent = proximalElement.component; + eventManager = proximalComponent.eventManager; + + numberFieldElement.blur(); + eventManager.activeTarget = null; + }); + + xit("should focus on a target when a target's own element receives focus", function () { + proximalElement.focus(); + expect(eventManager.activeTarget).toBe(proximalComponent); + expect(proximalComponent.isActiveTarget).toBeTruthy(); + }); + + if (!window.PointerEvent && !(window.MSPointerEvent && window.navigator.msPointerEnabled)) { + it("should focus on a target when a target's own element receives touchstart", function () { + testPage.touchEvent({target: proximalElement}, "touchstart"); + expect(eventManager.activeTarget).toBe(proximalComponent); + expect(proximalComponent.isActiveTarget).toBeTruthy(); + }); + + it("should focus on a target when a target's own element receives mousedown", function () { + testPage.mouseEvent({target: proximalElement}, "mousedown"); + expect(eventManager.activeTarget).toBe(proximalComponent); + expect(proximalComponent.isActiveTarget).toBeTruthy(); + }); + } + + }); + + }); + + }); +}); diff --git a/ui/control.js b/ui/control.js index 2e69aa1b87..b4b4d9e84d 100644 --- a/ui/control.js +++ b/ui/control.js @@ -187,15 +187,19 @@ var Control = exports.Control = Component.specialize(/** @lends module:montage/u value: /INPUT|TEXTAREA|A|SELECT|BUTTON|LABEL/ }, + __elementNeedsTabIndex: { + value: undefined + }, _elementNeedsTabIndex: { - value: function () { - return this.element.tagName.match(this._elementNeedsTabIndexRegex) === null; + get: function () { + return this.__elementNeedsTabIndex !== undefined ? this.__elementNeedsTabIndex + : (this.__elementNeedsTabIndex = (this.element.tagName.match(this._elementNeedsTabIndexRegex) === null)); } }, draw: { - value: function () { - if (this._elementNeedsTabIndex()) { + value: function Control_draw () { + if (this._elementNeedsTabIndex) { if (this._preventFocus) { this.element.removeAttribute("tabindex"); } else { @@ -217,7 +221,7 @@ var Control = exports.Control = Component.specialize(/** @lends module:montage/u get: function () { //Should the be done in focus instead? var shouldBeginEditing = this.callDelegateMethod("shouldBeginEditing", this); - return (shouldBeginEditing !== false); + return !this.disabled && (shouldBeginEditing !== false); } }, @@ -252,7 +256,7 @@ var Control = exports.Control = Component.specialize(/** @lends module:montage/u /** Specifies whether the button should receive focus or not. @type {boolean} - @event longpress + @event longpress */ preventFocus: { get: function () { @@ -333,10 +337,15 @@ var Control = exports.Control = Component.specialize(/** @lends module:montage/u if (this.converter) { var convertedValue; try { - //Where is the matching convert? - convertedValue = this.converter.revert(value); + //isActiveTarget is set by EventManager. If true, the control + //is being interracted with by the user. + convertedValue = this.isActiveTarget + ? this.converter.revert(value) + : this.converter.convert(value); this.error = null; this._value = convertedValue; + // if(this.isActiveTarget) console.log("isActiveTarget: revert value"); + // else console.log("convert value"); } catch (e) { // unable to convert - maybe error this._value = value; diff --git a/ui/text-field.info/sample/ui/main.reel/main.html b/ui/text-field.info/sample/ui/main.reel/main.html index df6dbb81a6..b375ade2d2 100644 --- a/ui/text-field.info/sample/ui/main.reel/main.html +++ b/ui/text-field.info/sample/ui/main.reel/main.html @@ -15,6 +15,31 @@ "values": { "element": {"#": "text-field-native"} } + }, + + "numberField": { + "prototype": "montage/ui/text-field.reel", + "values": { + "element": {"#": "number-field"}, + "value":100, + "converter": {"@": "numberConverter"} + + } + }, + + "numberConverter": { + "prototype": "montage/core/converter/number-converter", + "values": { + "allowPartialConversion":true + } + }, + + "numberFieldValue": { + "prototype": "montage/ui/text.reel", + "values": { + "element": {"#": "number-field-value"}, + "value": {"<-":"@numberField.value"} + } } } @@ -25,7 +50,12 @@
Text Field Sample
- + + + + + +