Skip to content

Commit 5673f8f

Browse files
Merge pull request #128 from vpython/winputblur
attempt input onblur handling
2 parents a3a02fe + df8db00 commit 5673f8f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docker-datastore.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- 8081:8081
1212
volumes:
1313
- datastore:/root/.config
14-
command: gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --project glowscript-dev
14+
command: sh -c "gcloud beta emulators datastore start --host-port=0.0.0.0:8081 --project glowscript-dev"
1515

1616
volumes:
1717
datastore:

lib/glow/primitives.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,16 +2914,26 @@
29142914
attrs.jwinput = $('<input type="text" id="'+attrs._id+'"/>').val(attrs.text).appendTo(attrs.pos)
29152915
.css({"width":attrs.width.toString()+'px', "height":attrs.height.toString()+'px',
29162916
"font-size":(attrs.height-5).toString()+"px", "font-family":"sans-serif"})
2917-
.keypress( function(k) { if (k.keyCode == 13) { // 13 is Next
2917+
.keypress( function(k) {
2918+
if (k.keyCode == 13) { // 13 is Next
2919+
attrs.text = attrs.jwinput.val()
2920+
var ok = wparse()
2921+
if (!ok) {
2922+
alert('Numeric input error')
2923+
return
2924+
}
2925+
attrs.bind(cwinput)
2926+
}
2927+
})
2928+
.blur(function(k) {
29182929
attrs.text = attrs.jwinput.val()
29192930
var ok = wparse()
29202931
if (!ok) {
29212932
alert('Numeric input error')
29222933
return
29232934
}
29242935
attrs.bind(cwinput)
2925-
}
2926-
})
2936+
})
29272937

29282938
var cwinput = { // this structure implements a JavaScript "closure", essential for winput to work
29292939
get disabled() {return attrs.disabled},

0 commit comments

Comments
 (0)