Hi there
This is my customized 'Enter' key handler , for lister
- it there is an only one selected dir, it opens it
- it there is any file selected that belongs to some (currently hardcoded) filetype groups,
particulary image OR movie OR ... (music) ; it opens the standalone viewer - otherwise it fallbacks to default dblclk
I found the mismatch between image and movie to launch the standalone viewer was very annoying for me. I can not get anything up with @if
@ifset
etc
So here it is
function OnClick(clickData) {
var cmd = clickData.func.command;
cmd.deselect = false;
var srctab = clickData.func.sourcetab;
if ((srctab.selected_dirs.count == 1) && (srctab.selected_files.count == 0))
cmd.RunCommand("Go FROMSEL");
else if(_match_ftgrp(srctab.selected_files))
cmd.RunCommand("Show AUTOFILELIST");
else
cmd.RunCommand("FileType ACTION=shellex"); }
var _FTGRP_NAMES = ["2D Images", "3D Images", "Movies", "Music"];
function _match_ftgrp(seld_files) {
return any(seld_files, function(seld_f) {
return any(_FTGRP_NAMES, function(ftgrp_name) {
ftgrp = DOpus.filetypegroups.GetGroup(ftgrp_name);
return ftgrp.MatchExt(seld_f.name); }); }); }
// high order funcs
function any(coll, func) {
ok = false;
for (var e=new Enumerator(coll), item=e.item(); !ok && !e.atEnd(); e.moveNext(), item=e.item()) {
ok = func(item); }
return ok; }
// v unused, free gift
function foreach(coll, func) {
for (var e=new Enumerator(coll), item=e.item(); !e.atEnd(); e.moveNext(), item=e.item()) {
func(item); } }
function map(coll, func) {
var res = [];
for (var e=new Enumerator(coll), item=e.item(); !e.atEnd(); e.moveNext(), item=e.item()) {
res.push(func(item)); }
return res; }
SEE
PS : that is my first dopus script