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) {
var pos = findItemPosition(data);
self.hadFocus = that.hasFocus();
//self.hadFocus = that.hasFocus();
that.gainFocus();
if (pos > -1) {
if (data.metaKey) {
@ -784,6 +784,16 @@ Ox.List = function(options, self) {
} else if (!isSelected(pos)) {
// click on unselected item
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) {
// click on empty area
@ -840,29 +850,17 @@ Ox.List = function(options, self) {
}
function singleclick(data) {
// these can't trigger on mousedown,
// this can't trigger on mousedown,
// since it could be a doubleclick
var pos = findItemPosition(data),
clickable, editable;
//alert('singleclick')
if (pos > -1) {
if (!data.metaKey && !data.shiftKey && isSelected(pos)) {
//alert('??')
if (self.selected.length > 1) {
// click on one of multiple selected items
//alert('!!')
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);
}
}
}
if (
!data.metaKey && !data.shiftKey
&& isSelected(pos) && self.selected.length > 1
) {
// click on one of multiple selected items
select(pos);
}
}
}