I'd like to detect different types of close-tab operations.. ie if the context-menu is used as right click > close tab... or if you open up a set of grouped-tabs which is supposed to close other tabs in the current lister, etc... Unfortunately there doesn't seem to be a way to detect this and modifiers aren't even detected with the script below when I replace tabs using grouped-tabs and hold down any modifier..
There doesn't appear to be any hook which is triggered when context menu is opened, or when a menu-item is selected ( I'm going to post this in suggestions ) so I am curious if there is another way to do this ( and I'd prefer not to write a hack such as, the user right clicked set a cooldown var and if tab closed within the duration of the cooldown then allow it; I'd rather simply detect - but this type of hack may be acceptable on loading grouped-tabs for now until the hook is added )...
// Lock State of Tab Object - Can be: "off", "on", "changes", "reuse"
var _state = _tab.lock;
// Is the tab locked ( any state )
var _locked = ( _state != "off" ) ? true : false;
// Key Modifiers held while trying to close tab... - Can be: "none", "shift", "ctrl", "alt", "shift,ctrl", "shift,alt", "shift,ctrl,alt", "ctrl,alt"
var _mods = _data.qualifiers;
var _modded = ( _mods != "none" ) ? true : false;
// Prevent closing the tab if the tab is locked and no mods are pressed...
if ( _locked && !_modded )
return true;
Please add scripting hooks for when the context-menu is opened and, even more important, when a menu-item is selected...
For example, right now function OnCloseTab( _data ) has no idea where the close-command was called from.. I'd like to be able to see if someone uses the context-menu and chooses close ( because then I'd allow the tab to be closed, even if locked; right now I do not allow locked tabs to be closed unless a modifier is pressed but this is bugged and won't work when opening grouped-tabs while holding a modifier... ie opening grouped-tab list and holding shift which would otherwise cause the locked tab to be closed, won't work )..
Basically I'd like to detect where something was called from ( and this can be applied to all functions ) so if OnCloseTab was triggered from Grouped-Tabs Opening with the option selected to close all other tabs then I want to detect this and allow the tab to be closed...
// Lock State of Tab Object - Can be: "off", "on", "changes", "reuse"
var _state = _tab.lock;
// Is the tab locked ( any state )
var _locked = ( _state != "off" ) ? true : false;
// Key Modifiers held while trying to close tab... - Can be: "none", "shift", "ctrl", "alt", "shift,ctrl", "shift,alt", "shift,ctrl,alt", "ctrl,alt"
var _mods = _data.qualifiers;
var _modded = ( _mods != "none" ) ? true : false;
// Prevent closing the tab if the tab is locked and no mods are pressed...
if ( _locked && !_modded )
return true;
Why not add a separate argument, using enumeration as the identifier, to the callback? The function to close a tab has to be called from each user-input location such as context-menu, hotkeys / binds, etc.. Whether the function itself calls the callback or the actual action of it closing is how it is called.. it doesn't matter.. You can add an additional argument or you can set a variable in the object depending how it is called.. Both ways will work...