79495768

Date: 2025-03-09 10:34:32
Score: 0.5
Natty:
Report link

The only solution I have found is to have a global Input.input.addEventListener() call (rather than adding an event listener per context menu) and through it call a global callback that is updated by the context menus.

// Weak map mapping to Input listeners of submenus reliably.
// The keys are the submenu lists themselves, not the submenu representing items.
const submenuInputPressedListeners = new WeakMap<HTMLDivElement, Function>();

// Globalized input action listener
Input.input.addEventListener("inputPressed", function(): void
{
    currentInputPressedListener?.();
});

(Updated with either currentInputPressedListener = input_onInputPressed; or currentInputPressedListener = null;, instead of Input.input.addEventListener or removeEventListener)

Now am I doing this to test navigation input on submenus from outer context menus:

// Check input on submenu
submenuInputPressedListeners.get(submenus[submenus.length - 1])();
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Matheus Dias de Souza