I noticed that in checkbox mode, the Insert key (Select NEXT=nodeselect
) changes the visual selection, not the checkbox status. I thought I could change that with a plugin, but the solution I came out with (below) has the inconvenient of the screen flickering because of the checkbox off/on trick to find the focused element. Any idea to improve this?
function OnSelectAndNext(data) {
var tab = data.func.sourcetab;
if (tab.all.Count === 0)
return;
var cmd = data.func.command;
if (cmd.IsSet('CHECKBOXMODE=off'))
return;
// remember which items were selected
var was_selected = toArray(tab.selected);
// turn checkbox mode off (it remembers the checkboxes)
// after this, tab.selected reflects the visual selection
cmd.RunCommand('Set CHECKBOXMODE=off');
// select THIS: selects the focused item
cmd.RunCommand('Select THIS');
tab.selected.Update();
var focused;
if (tab.selected.Count === 0)
focused = null; // focus is on ".."
else
focused = tab.selected(0);
// turn back checkbox mode on
cmd.RunCommand('Set CHECKBOXMODE=on');
// select or deselect the focused item unless it is ".."
if (focused)
if (includesItem(was_selected, focused))
cmd.RunCommand('Select "' + focused.name + '" EXACT DESELECT');
else
cmd.RunCommand('Select "' + focused.name + '" EXACT');
// move to the next item, unless we are at the end
if (!focused || lastElement(tab.all).name !== focused.name)
cmd.RunCommand('Select NEXT IGNORECHECKBOXMODE');
}