DgsMenuHide

From Multi Theft Auto: Wiki
Revision as of 04:28, 10 July 2025 by Mohab (talk | contribs) (Created page with "{{client function}} __NOTOC__ This function hides a DGS menu and cleans up any associated submenus. ==Syntax== <syntaxhighlight lang="lua"> bool dgsMenuHide ( element menu ) </syntaxhighlight> ===Required Arguments=== *'''menu:''' The DGS menu element to hide ===Returns=== Returns ''true'' if the menu was hidden successfully, ''false'' otherwise. ==Examples== <syntaxhighlight lang="lua"> loadstring(exports.dgs:dgsImportFunction())()-- load functions -- Create a menu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function hides a DGS menu and cleans up any associated submenus.

Syntax

bool dgsMenuHide ( element menu )

Required Arguments

  • menu: The DGS menu element to hide

Returns

Returns true if the menu was hidden successfully, false otherwise.

Examples

loadstring(exports.dgs:dgsImportFunction())()-- load functions

-- Create a menu
local menu = dgsCreateMenu(200, 200, 150, 120, false)
dgsMenuAddItem(menu, "New File", "new")
dgsMenuAddItem(menu, "Open File", "open")
dgsMenuAddSeparator(menu)
dgsMenuAddItem(menu, "Exit", "exit")

-- Show the menu
dgsMenuShow(menu)

-- Handle menu selection
addEventHandler("onDgsMenuSelect", menu, function(subMenu, uniqueID)
    if uniqueID == -1 then return end

    local command = dgsMenuGetItemCommand(source, uniqueID)
    if command == "exit" then
        dgsMenuHide(source)
        outputChatBox("Menu closed!")
    else
        outputChatBox("Selected: " .. command)
    end
end, false)

Notes

[[{{{image}}}|link=|]] Note: This function automatically cleans up submenus and removes focus from the menu
[[{{{image}}}|link=|]] Note: Menus are automatically hidden when losing focus if autoHide property is enabled (default)

See Also

Author

Mohab.