From f4e5f84c58ef7ff815f9552275261b527c69ef74 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 2 Aug 2014 18:04:47 -0400 Subject: [PATCH] Add an 'hide()' method for menus --- README.md | 1 + base.lua | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 428c150..f1fe2b4 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ here is the list: | clear | Remove all items | --- | --- | | scroll_down | If the menu is cropped, scroll down | --- | --- | | scroll_up | If the menu is cropped, scroll up | --- | --- | +| hide | Hide a menu and all sub menus | --- | --- | | swap | Swap 2 items | both items | --- | | move | Move an item | the item, the new idx | --- | | remove | Remove the item | the item | --- | diff --git a/base.lua b/base.lua index 2dfcbe5..e6e20e0 100644 --- a/base.lua +++ b/base.lua @@ -544,6 +544,17 @@ local function new(args) end end + function data:hide() + data.visible = false + if data.parent_geometry and data.parent_geometry.is_menu then + local parent = data.parent_geometry + while parent do + parent.visible = false + parent = parent.parent_geometry and parent.parent_geometry.is_menu and parent.parent_geometry + end + end + end + if private_data.layout then private_data.layout:setup_key_hooks(data) end