--- title: Buttons and standard UI extensions summary: Add an action or row while retaining normal menu behavior. section: ui kind: guide status: reference tags: ["X4","modding","extend","ui"] sources: ["https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/Breaking%20Changes/"] --- ## Find an extension surface Find the relevant menu and callback in your game version. Prefer an existing extension point or suitable community API. When wrapping an internal function, preserve the original and ordinary path. A new feature may use its own window; another mod's layout is not a universal requirement. ## Obtain the menu The lookup below is a fragment, not complete hook installation. Retry at an appropriate lifecycle point if the menu does not yet exist. Do not install another wrapper on every frame. ```lua local menu = Helper and Helper.getMenu and Helper.getMenu("MapMenu") if not menu then return end ``` ## Add a button Place the fragment in your own table builder, where `t` is an existing Helper table. Connect it to your [MD handler](wiki:md-lua-bridge). Do not display game-action completion before an observed result. ```lua local row = t:addRow(true, {}) row[1]:createButton({ height = 28 }):setText("My action") row[1].handlers.onClick = function() AddUITriggeredEvent("WikiPanel", "apply", "example") end ``` ## Behavior and refresh Table rebuilds can emit callbacks resembling user input. Check event source, selected row and owning table, and ensure redraw does not repeat an action. Change only necessary rows; retain availability checks for unrelated objects. Recheck internal signatures after game updates.