Table of Contents

Class CommandBridge

Namespace
Terminal.Gui.Input
Assembly
Terminal.Gui.dll

Bridges command routing across non-containment boundaries (e.g., between a MenuBarItem and its PopoverMenu, which is registered with Application.Popover rather than the SuperView hierarchy).

public class CommandBridge : IDisposable
Inheritance
CommandBridge
Implements
Inherited Members

Remarks

The bridge subscribes to the remote view's Accepted and/or Activated events. When fired, it creates a new CommandContext with Bridged routing and invokes the command on the owner via InvokeCommand(Command, ICommandContext?). This re-enters the full command pipeline (RaiseActivating/RaiseAccepting → TryDispatchToTarget → TryBubbleUp → RaiseActivated/RaiseAccepted), enabling bridged commands to propagate through the owner's SuperView hierarchy.

Both references are weak — the bridge does not prevent GC of either view. The bridge becomes inert if either WeakReference<T> target is collected.

The bridge is one-way: remote fires event → owner receives command. If bidirectional routing is needed, create two bridges.

Methods

Connect(View, View, params Command[])

Connects an owner view to a remote view for the specified commands. When the remote view raises Accepted or Activated for any of the specified commands, the owner view receives the command with Bridged routing.

Dispose()

Tears down event subscriptions. Safe to call multiple times.