1
0
Fork 0
forked from 0x2620/oxjs

fix a bug where space key wouldn't register while autocomplete menu was open

This commit is contained in:
rolux 2011-05-20 09:14:24 +02:00
commit 6e0bafed88
3 changed files with 42 additions and 27 deletions

View file

@ -305,16 +305,37 @@ Ox.Input = function(options, self) {
var length = self.options.value.length,
deleted = length <= oldValue.length - (oldCursor[1] - oldCursor[0]),
newValue = values[0] ?
((self.options.autocompleteReplaceCorrect || !deleted) ?
values[0] : self.options.value) :
(self.options.autocompleteReplaceCorrect ? oldValue : self.options.value),
newLength = newValue.length,
newValue, newLength,
pos = cursor(),
selected = -1,
selectEnd = length == 0 || (values[0] && values[0].length),
value;
if (values[0]) {
if (self.options.autocompleteReplaceCorrect || !deleted) {
newValue = values[0];
} else {
newValue = self.options.value;
}
} else {
if (self.options.autocompleteReplaceCorrect) {
newValue = oldValue;
} else {
newValue = self.options.value
}
}
newLength = newValue.length;
/*
if (self.options.autocompleteReplaceCorrect) {
if (values[0]) {
newValue = deleted ? oldValue : values[0];
} else {
newValue = self.options.value;
}
}
*/
//Ox.print('selectEnd', selectEnd)
if (self.options.autocompleteReplace) {
@ -380,22 +401,9 @@ Ox.Input = function(options, self) {
}
//size: self.options.size
})
.addClass('OxAutocompleteMenu')
.bindEvent({
click: clickMenu,
key_left: function() {
cursor(cursor()[0] - 1);
},
key_right: function() {
cursor(cursor()[0] + 1);
},
key_shift_left: function() {
var cursor = cursor();
cursor(cursor[0] - 1, cursor[1]);
},
key_shift_right: function() {
var cursor = cursor();
cursor(cursor[0], cursor[1] + 1);
}
click: clickMenu
});
if (self.options.autocompleteReplace) {
menu.bindEvent({