Bug 985853 - [Keyboard UX update][User Story] Hold shift to enter upper ... #23456
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
/* global KeyEvent */ | ||
/* global KeyEvent, IMERender */ | ||
|
||
(function(exports) { | ||
|
||
|
@@ -79,6 +79,11 @@ DefaultTargetHandler.prototype.doubleTap = function() { | |
this.app.console.log('DefaultTargetHandler.doubleTap()'); | ||
this.commit(); | ||
}; | ||
DefaultTargetHandler.prototype.newTargetActivate = function() { | ||
this.commit(); | ||
// Ignore any action when commit. | ||
this.ignoreCommitActions = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need |
||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the target handler doesn't end it's life when this function is called, you need to set
here. |
||
|
||
var NullTargetHandler = function(target, app) { | ||
DefaultTargetHandler.apply(this, arguments); | ||
|
@@ -231,11 +236,28 @@ var CapsLockTargetHandler = function(target, app) { | |
DefaultTargetHandler.apply(this, arguments); | ||
}; | ||
CapsLockTargetHandler.prototype = Object.create(DefaultTargetHandler.prototype); | ||
CapsLockTargetHandler.prototype.capsLockState = 'none'; | ||
CapsLockTargetHandler.prototype.newTargetActivated = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, it turned out How about |
||
CapsLockTargetHandler.prototype.activate = function() { | ||
if (this.app.upperCaseStateManager.isUpperCaseLocked) { | ||
this.capsLockState = 'upperCaseLocked'; | ||
} else if (this.app.upperCaseStateManager.isUpperCase) { | ||
this.capsLockState = 'upperCase'; | ||
} else { | ||
this.capsLockState = 'none'; | ||
} | ||
this.app.feedbackManager.triggerFeedback(this.target); | ||
this.app.visualHighlightManager.show(this.target); | ||
}; | ||
CapsLockTargetHandler.prototype.commit = function() { | ||
// If hold shift to enter upper case, set isUpperCase false when finished | ||
this.app.upperCaseStateManager.switchUpperCaseState({ | ||
isUpperCase: !this.app.upperCaseStateManager.isUpperCase, | ||
isUpperCase: this.newTargetActivated ? false : | ||
!this.app.upperCaseStateManager.isUpperCase, | ||
isUpperCaseLocked: false | ||
}); | ||
this.newTargetActivated = false; | ||
this.capsLockState = 'none'; | ||
this.app.visualHighlightManager.hide(this.target); | ||
}; | ||
CapsLockTargetHandler.prototype.doubleTap = function() { | ||
|
@@ -244,6 +266,13 @@ CapsLockTargetHandler.prototype.doubleTap = function() { | |
}); | ||
this.app.visualHighlightManager.hide(this.target); | ||
}; | ||
CapsLockTargetHandler.prototype.newTargetActivate = function() { | ||
this.newTargetActivated = true; | ||
this.app.upperCaseStateManager.switchUpperCaseState({ | ||
isUpperCaseLocked: true | ||
}); | ||
IMERender.highlightKey(this.target, { capsLockState: this.capsLockState }); | ||
}; | ||
|
||
var SwitchKeyboardTargetHandler = function(target, app) { | ||
DefaultTargetHandler.apply(this, arguments); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ TargetHandlersManager.prototype.start = function() { | |
this._callTargetAction.bind(this, 'cancel', false, true); | ||
activeTargetsManager.ontargetdoubletapped = | ||
this._callTargetAction.bind(this, 'doubleTap', false, true); | ||
activeTargetsManager.onnewtargetwillactivate = | ||
this._callTargetAction.bind(this, 'newTargetActivate', false, false); | ||
activeTargetsManager.start(); | ||
}; | ||
|
||
|
@@ -61,6 +63,9 @@ TargetHandlersManager.prototype.stop = function() { | |
// "longpress" is noticeably an optional step during the life cycle and does | ||
// not start or end the handler/active target, so it was not mentioned in the | ||
// above list. | ||
// "newTargetActivate" is similar to "longpress", it is an optional step too, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please leave a brief comment on when |
||
// so it was not mentioned in the above list. When newTargetActivate is called, | ||
// isUpperCase will be set to true, and hold the icon's background. | ||
// | ||
// Please note that since we are using target (an abstract key object associated | ||
// with one DOM element) as the identifier of handlers, we do not assign new | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we can do here is remove this code, and introduce an interface between targetHandlersManager and targetHandler to have each of the target handler to decide whether or not it should be committed when a new target is activated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g.
and
and have
TargetHandlersManager
atontargetactivated
do things differently against the existing targets.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.... ok. After giving another thought on this, we should still remove the code here in active target manager, but I think we shouldn't need a
COMMIT_WITH_ANOTHER_PRESS
flag on handlers. What we should do is introduce aonanotherpressactivated
callback to each of the handlers and have the handlers to commit/ignore on it's own. Default handler, for example, could call it's ownthis.commit()
and then setthis.ignoreCommitActions = true
to itself.Does that make sense more? I just try to find a way to generalize
*Managers
(bad name, I know) as much as possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
onanotherpresswillactivate
since this call should happen beforeonactivate
of another handler?