Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
d609675c
Commit
d609675c
authored
Feb 23, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69 from smalruby/fix_ime_bug
Fixed issue with pressed enter key with IME.
parents
0b1efa2e
033a6b88
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
core/field_textinput.js
core/field_textinput.js
+22
-8
No files found.
core/field_textinput.js
View file @
d609675c
...
...
@@ -132,7 +132,10 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
htmlInput
.
select
();
}
// Bind to keyup -- trap Enter and Esc; resize after every keystroke.
// Bind to keydown -- trap Enter without IME and Esc to hide.
htmlInput
.
onKeyDownWrapper_
=
Blockly
.
bindEvent_
(
htmlInput
,
'
keydown
'
,
this
,
this
.
onHtmlInputKeyDown_
);
// Bind to keyup -- trap Enter; resize after every keystroke.
htmlInput
.
onKeyUpWrapper_
=
Blockly
.
bindEvent_
(
htmlInput
,
'
keyup
'
,
this
,
this
.
onHtmlInputChange_
);
// Bind to keyPress -- repeatedly resize when holding down a key.
...
...
@@ -145,20 +148,30 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
};
/**
* Handle
a change
to the editor.
* Handle
key down
to the editor.
* @param {!Event} e Keyboard event.
* @private
*/
Blockly
.
FieldTextInput
.
prototype
.
onHtmlInput
Change
_
=
function
(
e
)
{
Blockly
.
FieldTextInput
.
prototype
.
onHtmlInput
KeyDown
_
=
function
(
e
)
{
var
htmlInput
=
Blockly
.
FieldTextInput
.
htmlInput_
;
if
(
e
.
keyCode
==
13
)
{
// Enter
var
enterKey
=
13
,
escKey
=
27
;
if
(
e
.
keyCode
==
enterKey
)
{
Blockly
.
WidgetDiv
.
hide
();
}
else
if
(
e
.
keyCode
==
27
)
{
// Esc
}
else
if
(
e
.
keyCode
==
escKey
)
{
this
.
setText
(
htmlInput
.
defaultValue
);
Blockly
.
WidgetDiv
.
hide
();
}
else
{
}
};
/**
* Handle a change to the editor.
* @param {!Event} e Keyboard event.
* @private
*/
Blockly
.
FieldTextInput
.
prototype
.
onHtmlInputChange_
=
function
(
e
)
{
var
htmlInput
=
Blockly
.
FieldTextInput
.
htmlInput_
;
var
escKey
=
27
;
if
(
e
.
keyCode
!=
escKey
)
{
// Update source block.
var
text
=
htmlInput
.
value
;
if
(
text
!==
htmlInput
.
oldValue_
)
{
...
...
@@ -238,6 +251,7 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
}
thisField
.
setText
(
text
);
thisField
.
sourceBlock_
.
rendered
&&
thisField
.
sourceBlock_
.
render
();
Blockly
.
unbindEvent_
(
htmlInput
.
onKeyDownWrapper_
);
Blockly
.
unbindEvent_
(
htmlInput
.
onKeyUpWrapper_
);
Blockly
.
unbindEvent_
(
htmlInput
.
onKeyPressWrapper_
);
Blockly
.
unbindEvent_
(
htmlInput
.
onWorkspaceChangeWrapper_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment