fix a bug in text lists where selecting an item by clicking on an editable cell would click through to edit

This commit is contained in:
rlx 2011-09-20 04:10:04 +00:00
parent b881f74c7e
commit fdecafe4d7

View file

@ -765,7 +765,7 @@ Ox.List = function(options, self) {
function mousedown(data) { function mousedown(data) {
var pos = findItemPosition(data); var pos = findItemPosition(data);
self.hadFocus = that.hasFocus(); //self.hadFocus = that.hasFocus();
that.gainFocus(); that.gainFocus();
if (pos > -1) { if (pos > -1) {
if (data.metaKey) { if (data.metaKey) {
@ -784,6 +784,16 @@ Ox.List = function(options, self) {
} else if (!isSelected(pos)) { } else if (!isSelected(pos)) {
// click on unselected item // click on unselected item
select(pos); select(pos);
} else if (self.options.type == 'text') {
$cell = findCell(data);
if ($cell) {
clickable = $cell.is('.OxClickable');
editable = $cell.is('.OxEditable') && !$cell.is('.OxEdit');
if (clickable || editable) {
// click on a clickable or editable cell
triggerClickEvent(clickable ? 'click' : 'edit', self.$items[pos], $cell);
}
}
} }
} else if (!$(data.target).is('.OxToggle') && self.options.min == 0) { } else if (!$(data.target).is('.OxToggle') && self.options.min == 0) {
// click on empty area // click on empty area
@ -840,29 +850,17 @@ Ox.List = function(options, self) {
} }
function singleclick(data) { function singleclick(data) {
// these can't trigger on mousedown, // this can't trigger on mousedown,
// since it could be a doubleclick // since it could be a doubleclick
var pos = findItemPosition(data), var pos = findItemPosition(data),
clickable, editable; clickable, editable;
//alert('singleclick')
if (pos > -1) { if (pos > -1) {
if (!data.metaKey && !data.shiftKey && isSelected(pos)) { if (
//alert('??') !data.metaKey && !data.shiftKey
if (self.selected.length > 1) { && isSelected(pos) && self.selected.length > 1
) {
// click on one of multiple selected items // click on one of multiple selected items
//alert('!!')
select(pos); select(pos);
} else if (self.options.type == 'text' && self.hadFocus) {
$cell = findCell(data);
if ($cell) {
clickable = $cell.is('.OxClickable');
editable = $cell.is('.OxEditable') && !$cell.is('.OxEdit');
if (clickable || editable) {
// click on a clickable or editable cell
triggerClickEvent(clickable ? 'click' : 'edit', self.$items[pos], $cell);
}
}
}
} }
} }
} }