summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/MirLua/docs/examples/core.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/MirLua/docs/examples/core.lua b/plugins/MirLua/docs/examples/core.lua
index 5e253ea0d2..d72ce0c18f 100644
--- a/plugins/MirLua/docs/examples/core.lua
+++ b/plugins/MirLua/docs/examples/core.lua
@@ -1,11 +1,22 @@
-- core module (m) is included by default
--- include m_clist module
local clist = require('m_clist')
+--- include m_genmenu module
+local genmenu = require('m_genmenu')
-- include m_icolib module
local icolib = require('m_icolib')
-- Add icon for menu items
local hRestartIcon = icolib.AddIcon('restartIcon', 'Restart')
--- Add menu item to main menu that allow to restart Miranda NG
-clist.AddMainMenuItem("Restart", 0, 0, hRestartIcon, "Miranda/System/Restart")
+-- Subscribe to Lua script loaded event
+m.OnScriptLoaded(function()
+ -- Add menu item to main menu that allow to restart Miranda NG
+ hRestartMenuItem = clist.AddMainMenuItem({ Name = "Restart", Icon = hRestartIcon, Service = "Miranda/System/Restart" })
+end)
+
+-- Subscribe to Lua script unload event
+m.OnScriptUnload(function()
+ -- remove menu item from main menu
+ hRestartMenuItem = genmenu.RemoveMenuItem(hRestart)
+end)