Copy\Move to last active source?

Improvement when using the Opus 13 dynamic label version:

The label width may change a lot when the path/variable changes, but toolbars won't know to update their layouts to suit the new width unless they're told.

You can do that by adding this line to the bottom of StoreLastSource in the script:

DOpus.Create.Command.UpdateToggle();
Full modified script
function OnInit(initData) {
    initData.name = 'LogLastSource';
    initData.version = '2023-10-06';
    initData.url = 'https://resource.dopus.com/t/copy-move-to-last-active-source/46183';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

var vec = DOpus.Create().Vector();

function StoreLastSource(tab) {
    if (!tab) return;
    if (!tab.path) return;

    vec.push_back(tab.path);
    if (vec.count > 2) vec.erase(0);

    DOpus.Vars.Set('lastSource', vec(0));
    // DOpus.Output('lastSource: ' + vec(0));

    DOpus.Create.Command.UpdateToggle();
}

function OnActivateLister(activateListerData) {
    if (activateListerData.active) return;
    StoreLastSource(activateListerData.lister.activetab);
}

(If anyone finding this needs to do similar with a non-script button, you can use @toggle:update for a similar effect.)

2 Likes