Skip to content

Commit 9ae43ca

Browse files
TaroEldLordMidas
authored andcommitted
feat: add keybind to lock nested tooltips
1 parent a771f82 commit 9ae43ca

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
::MSU.QueueBucket.AfterHooks.push(function() {
2-
::MSU.Mod.Keybinds.addJSKeybind("LockTooltip", "rightclick", "Lock Tooltip", "Instantly locks a tooltip, skipping the timer.");
2+
::MSU.Mod.Keybinds.addJSKeybind("LockTooltip", "rightclick", "Lock Tooltip (Mouse)", "Instantly locks a tooltip, skipping the timer. Use a MOUSE key.");
3+
::MSU.Mod.Keybinds.addJSKeybind("LockTooltipKeyboard", "ctrl+1", "Lock Tooltip (Keyboard)", "Instantly locks a tooltip, skipping the timer. UIse a KEYBOARD key.");
34
});

ui/mods/msu/nested_tooltips.js

+20
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ MSU.NestedTooltip = {
158158
{
159159
return this.__tooltipStack.length === 0;
160160
},
161+
getTopOfStack : function ()
162+
{
163+
return this.isStackEmpty() ? null : this.__tooltipStack[this.__tooltipStack.length - 1];
164+
},
161165
removeTopTooltip : function()
162166
{
163167
this.removeTooltip(this.__tooltipStack[this.__tooltipStack.length-1]);
@@ -456,6 +460,22 @@ $(document).on('mouseenter.msu-tooltip-source', '.msu-nested-tooltip', function(
456460
MSU.NestedTooltip.getBindFunction(data).call(this);
457461
})
458462

463+
// key listener for the LockTooltipKeyboard keybind
464+
document.addEventListener('keydown', function( _event )
465+
{
466+
if (!MSU.Keybinds.isKeybindPressed(MSU.ID, "LockTooltipKeyboard", _event))
467+
return;
468+
var stackData = MSU.NestedTooltip.getTopOfStack();
469+
if (stackData == null)
470+
return;
471+
var progressImage = stackData.tooltip.container.find(".tooltip-progress-bar");
472+
if (!progressImage)
473+
return;
474+
_event.stopPropagation();
475+
progressImage.velocity("finish");
476+
return;
477+
});
478+
459479
TooltipModule.prototype.showTileTooltip = function()
460480
{
461481
if (this.mCurrentData === undefined || this.mCurrentData === null)

0 commit comments

Comments
 (0)