Plugin:MirLua/Module/m genmenu: Difference between revisions

From Miranda NG
Jump to navigation Jump to search
m (Goraf moved page Plugin:MirLua/Module/m genmenu to Plugin:MirLua/Module/m genmenu: to transform to translation system)
(make it translatable; (needs small translations from Russian))
Line 1: Line 1:
{{PageLang|en}}
<languages/>
<translate>
Allows you to access menu subsystem.
Allows you to access menu subsystem.
</translate>


Include module: <code>local genmenu = require('m_genmenu')</code>
{{Ls|MirLua/Modules/include_info}} <code>local genmenu = require('m_genmenu')</code>


{{Note|Parameters written in '''''bold italics''''' are obligatory.}}
__TOC__
 
<translate>
== Functions ==
</translate>
 
=== ModifyMenuItem ===
<translate>Modifies menu item.</translate>
 
==== {{Ls|MirLua/Modules/parameters}} ====
{| class="wikitable"
|-
! scope="col" | {{Ls|MirLua/Modules/param_name}}
! scope="col" | {{Ls|MirLua/Modules/required_param}}
! scope="col" | {{Ls|Content/TableHeaders/type}}
! scope="col" | {{Ls|Content/TableHeaders/description}}
|-
! scope="row" class="MirLuaParametersTable-parameter" | hMenuItem
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Menu item handle.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | name
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>New menu item name or <tvar|nil><code>nil</code></>.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | icon
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>[[<tvar|link>Special:MyLanguage/Plugin:MirLua/Module/m_icolib#AddIcon</>|Icon handle]] or <tvar|INVALID_HANDLE_VALUE><code>[[Special:MyLanguage/Plugin:MirLua/Module/m_core#INVALID_HANDLE_VALUE|INVALID_HANDLE_VALUE]]</code></>.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | flags
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>number</code>
| <translate>Additional flags or <tvar|value_-1><code>-1</code></>.</translate>
|}
 
==== {{Ls|MirLua/Modules/result}} ====
{{nbsp|5}}{{Ls|MirLua/Modules/type}} <code>boolean</code>


{{nbsp|5}}<translate>Returns <tvar|true><code>true</code></> on success, otherwise <tvar|false><code>false</code></>.</translate>


__TOC__
==== {{Ls|MirLua/Modules/example}} ====
{{Content:MirLua/Example|code=local hMenuItem = genmenu.ModifyMenuItem(hMenuItem, 'New name', m.INVALID_HANDLE_VALUE)}}
----


== Functions ==
=== ConfigureMenuItem ===
=== CreateRoot ===
Дополнительная настройка пункта меню.
Creates root menu item.
;Parameters
: '''''hMenuObject'''''
:: Type: '''number'''
:: Global menu handle.
: '''''name'''''
:: Type: '''string'''
:: Menu item name.
: ''position''
:: Type: '''number'''
:: Menu item position.
: ''icon''
:: Type: '''light userdata'''
:: [[Plugin:MirLua/en/m_icolib#AddIcon|Icon]] handle.
;Result
: Type: '''light userdata'''
: If success, returns menu item handle, otherwise '''nil'''.
;Example
{{Content:MirLua/Example|code=local hMenuItem = genmenu.CreateRoot(genmenu.MO_MAIN)}}


<!--
==== {{Ls|MirLua/Modules/parameters}} ====
=== AddMenuItem ===
{| class="wikitable"
Creates menu item.
|-
;Parameters
! scope="col" | {{Ls|MirLua/Modules/param_name}}
: '''''hMenuObject'''''
! scope="col" | {{Ls|MirLua/Modules/required_param}}
:: Type: '''number'''
! scope="col" | {{Ls|Content/TableHeaders/type}}
:: Global menu handle.
! scope="col" | {{Ls|Content/TableHeaders/description}}
: '''''menuItem'''''
|-
:: Type: '''table'''
! scope="row" class="MirLuaParametersTable-parameter" | hMenuItem
:: [[#MenuItem|MenuItem]] table.
| style="text-align:center" | {{Ls|YesNo/yes}}
;Result
| style="text-align:center" | <code>light userdata</code>
: Type: '''light userdata'''
| <translate>Menu item handle.</translate>
: If success, returns menu item handle, otherwise '''nil'''.
|-
;Example
! scope="row" class="MirLuaParametersTable-parameter" | option
{{Content:MirLua/Example|code=
| style="text-align:center" | {{Ls|YesNo/yes}}
local hMenuItem = genmenu.AddMenuItem(genmenu.MO_MAIN, { Name = 'MyMenuItem'})
| style="text-align:center" | <code>number</code>
}}
| <translate></translate>
-->
|-
! scope="row" class="MirLuaParametersTable-parameter" | value
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Value of the option.</translate>
|}


=== ModifyMenuItem ===
Modifies menu item.
;Parameters
: '''''hMenuItem'''''
: '''''hMenuItem'''''
:: Type: '''light userdata'''
:: Тип: '''light userdata'''
:: Menu item handle.
:: Дескриптор пункта меню.
: '''''name'''''
: '''''option'''''
:: Type: '''string'''
:: Тип: ''''''number''''''
:: New menu item name or '''nil'''.
:: изменяемая настройка (1 - название; 2 - горячие клавиши; 3 - параметр для исполнения; 4 - UUID).
: '''''icon'''''
: '''''value'''''
:: Type: '''light userdata'''
:: Тип: '''light userdata'''
:: [[Plugin:MirLua/en/m_icolib#AddIcon|Icon]] handle or ''[[Plugin:MirLua/en/m_core#INVALID_HANDLE_VALUE|INVALID_HANDLE_VALUE]]''
:: значение.
: '''''flags'''''
 
:: Type: '''number'''
==== {{Ls|MirLua/Modules/result}} ====
:: Additional flags or ''-1''
{{nbsp|5}}{{Ls|MirLua/Modules/type}} <code>light userdata</code>
;Result
 
: Type: '''light userdata'''
{{nbsp|5}}<translate>Returns <tvar|true><code>true</code></> on success, otherwise <tvar|false><code>false</code></>.</translate>
: If success, returns menu item handle, otherwise '''nil'''.
----
;Example
{{Content:MirLua/Example|code=local hMenuItem = genmenu.CreateRoot(genmenu.MO_MAIN)}}


=== ShowMenuItem ===
=== ShowMenuItem ===
Shows/hides menu item.
<translate>Shows/hides menu item.</translate>
;Parameters
 
: '''''hMenuItem'''''
==== {{Ls|MirLua/Modules/parameters}} ====
:: Type: '''light userdata'''
{| class="wikitable"
:: Menu item handle.
|-
: '''''isShown'''''
! scope="col" | {{Ls|MirLua/Modules/param_name}}
:: Type: '''boolean'''
! scope="col" | {{Ls|MirLua/Modules/required_param}}
:: '''true''' to show menu item, '''false''' to hide it.
! scope="col" | {{Ls|Content/TableHeaders/type}}
;Example
! scope="col" | {{Ls|Content/TableHeaders/description}}
|-
! scope="row" class="MirLuaParametersTable-parameter" | hMenuItem
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Menu item handle.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | isShown
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>boolean</code>
| <translate>Pass <tvar|true><code>true</code></> to show menu item, <tvar|false><code>false</code></> to hide it.</translate>
|}
 
==== {{Ls|MirLua/Modules/example}} ====
{{Content:MirLua/Example|code=genmenu.ShowMenuItem(hMenuItem, true)}}
{{Content:MirLua/Example|code=genmenu.ShowMenuItem(hMenuItem, true)}}
----


=== EnableMenuItem ===
=== EnableMenuItem ===
Enables/disables menu item.
<translate>Enables/disables menu item.</translate>
;Parameters
 
: '''''hMenuItem'''''
==== {{Ls|MirLua/Modules/parameters}} ====
:: Type: '''light userdata'''
{| class="wikitable"
:: Menu item handle.
|-
: '''''isEnabled'''''
! scope="col" | {{Ls|MirLua/Modules/param_name}}
:: Type: '''boolean'''
! scope="col" | {{Ls|MirLua/Modules/required_param}}
:: '''true''' to enable menu item, '''false''' to disable it.
! scope="col" | {{Ls|Content/TableHeaders/type}}
;Example
! scope="col" | {{Ls|Content/TableHeaders/description}}
|-
! scope="row" class="MirLuaParametersTable-parameter" | hMenuItem
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Menu item handle.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | isEnabled
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>boolean</code>
| <translate>Pass <tvar|true><code>true</code></> to enable menu item, <tvar|false><code>false</code></> to disable it.</translate>
|}
 
==== {{Ls|MirLua/Modules/example}} ====
{{Content:MirLua/Example|code=genmenu.EnableMenuItem(hMenuItem, false)}}
{{Content:MirLua/Example|code=genmenu.EnableMenuItem(hMenuItem, false)}}
----


=== CheckMenuItem ===
=== CheckMenuItem ===
Checks/unchecks menu item.
<translate>Checks/unchecks menu item.</translate>
;Parameters
 
: '''''hMenuItem'''''
==== {{Ls|MirLua/Modules/parameters}} ====
:: Type: '''light userdata'''
{| class="wikitable"
:: Menu item handle.
|-
: '''''isChecked'''''
! scope="col" | {{Ls|MirLua/Modules/param_name}}
:: Type: '''boolean'''
! scope="col" | {{Ls|MirLua/Modules/required_param}}
:: '''true''' to enable menu item, '''false''' to disable it.
! scope="col" | {{Ls|Content/TableHeaders/type}}
;Example
! scope="col" | {{Ls|Content/TableHeaders/description}}
|-
! scope="row" class="MirLuaParametersTable-parameter" | hMenuItem
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Menu item handle.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | isChecked
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>boolean</code>
| <translate>Pass <tvar|true><code>true</code></> to check menu item, <tvar|false><code>false</code></> to uncheck it.</translate>
|}
 
==== {{Ls|MirLua/Modules/example}} ====
{{Content:MirLua/Example|code=genmenu.CheckMenuItem(hMenuItem, true)}}
{{Content:MirLua/Example|code=genmenu.CheckMenuItem(hMenuItem, true)}}
----


=== RemoveMenuItem ===
=== RemoveMenuItem ===
Removes menu item.
<translate>Removes menu item.</translate>
;Parameters
 
: '''''hMenuItem'''''
==== {{Ls|MirLua/Modules/parameters}} ====
:: Type: '''light userdata'''
{| class="wikitable"
:: Menu item handle.
|-
;Result
! scope="col" | {{Ls|MirLua/Modules/param_name}}
: Type: '''boolean'''
! scope="col" | {{Ls|MirLua/Modules/required_param}}
: If success, returns menu item handle, otherwise '''nil'''.
! scope="col" | {{Ls|Content/TableHeaders/type}}
;Example
! scope="col" | {{Ls|Content/TableHeaders/description}}
|-
! scope="row" class="MirLuaParametersTable-parameter" | hMenuItem
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Menu item handle.</translate>
|}
 
==== {{Ls|MirLua/Modules/result}} ====
{{nbsp|5}}{{Ls|MirLua/Modules/type}} <code>boolean</code>
 
{{nbsp|5}}<translate>Returns <tvar|true><code>true</code></> on success, otherwise <tvar|false><code>false</code></>.</translate>
 
==== {{Ls|MirLua/Modules/example}} ====
{{Content:MirLua/Example|code=genmenu.RemoveMenuItem(hMenuItem)}}
{{Content:MirLua/Example|code=genmenu.RemoveMenuItem(hMenuItem)}}


<translate>
== Structures ==
</translate>


== Structures ==
=== MenuItem ===
=== MenuItem ===
A table describing menu parameters.
<translate>A table describing menu parameters.</translate>
;Fields
: '''''Name'''''
:: Type: '''string'''
:: Menu item name (automatically translated by Core).
: ''Uid''
:: Type: '''string'''
:: Plugin UUID in format ''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx''.
: ''Service''
:: Type: '''string'''
:: [[Plugin:MirLua/en/m_core#CreateServiceFunction|Service function]] name.
: ''Position''
:: Type: '''number'''
:: Menu item position.
: ''Parent''
:: Type: '''light userdata'''
:: Parent menu handle.
: ''Icon''
:: Type: '''light userdata'''
:: [[Plugin:MirLua/en/m_icolib#AddIcon|Icon]] handle.
: ''Flags''
:: Type: '''number'''
:: Additional flags.


[[Category:Tutorials (en)]]
==== {{Ls|MirLua/Modules/fields}} ====
{| class="wikitable"
|-
! scope="col" | {{Ls|MirLua/Modules/field_name}}
! scope="col" | {{Ls|MirLua/Modules/required_param}}
! scope="col" | {{Ls|Content/TableHeaders/type}}
! scope="col" | {{Ls|Content/TableHeaders/description}}
|-
! scope="row" class="MirLuaParametersTable-parameter" | Name
| style="text-align:center" | {{Ls|YesNo/yes}}
| style="text-align:center" | <code>string</code>
| <translate>Menu item name (automatically translated by Core).</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | Uid
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>string</code>
| <translate>Plugin UUID in format <tvar|uuid_format>''<code>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</code>''</>.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | Service
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>string</code>
| [[Special:MyLanguage/Plugin:MirLua/Module/m_core#CreateServiceFunction|<translate>Service name.</translate>]]
|-
! scope="row" class="MirLuaParametersTable-parameter" | Position
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>number</code>
| <translate>Menu item position.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | Parent
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>light userdata</code>
| <translate>Parent menu handle.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | Icon
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>light userdata</code>
| [[Special:MyLanguage/Plugin:MirLua/Module/m_icolib#AddIcon|<translate>Icon handle.</translate>]]
|-
! scope="row" class="MirLuaParametersTable-parameter" | Flags
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>number</code>
| <translate>Additional flags.</translate>
|}

Revision as of 23:39, 2 June 2018

Other languages:
  • English

Allows you to access menu subsystem.

Include module: local genmenu = require('m_genmenu')

Functions

ModifyMenuItem

Modifies menu item.

Parameters

Parameter name Required Type Description
hMenuItem Yes light userdata Menu item handle.
name Yes light userdata New menu item name or nil.
icon Yes light userdata Icon handle or INVALID_HANDLE_VALUE.
flags No number Additional flags or -1.

Result

     Type: boolean

     Returns true on success, otherwise false.

Example

local hMenuItem = genmenu.ModifyMenuItem(hMenuItem, 'New name', m.INVALID_HANDLE_VALUE)

ConfigureMenuItem

Дополнительная настройка пункта меню.

Parameters

Parameter name Required Type Description
hMenuItem Yes light userdata Menu item handle.
option Yes number
value Yes light userdata Value of the option.
hMenuItem
Тип: light userdata
Дескриптор пункта меню.
option
Тип: 'number'
изменяемая настройка (1 - название; 2 - горячие клавиши; 3 - параметр для исполнения; 4 - UUID).
value
Тип: light userdata
значение.

Result

     Type: light userdata

     Returns true on success, otherwise false.


ShowMenuItem

Shows/hides menu item.

Parameters

Parameter name Required Type Description
hMenuItem Yes light userdata Menu item handle.
isShown Yes boolean Pass true to show menu item, false to hide it.

Example

genmenu.ShowMenuItem(hMenuItem, true)

EnableMenuItem

Enables/disables menu item.

Parameters

Parameter name Required Type Description
hMenuItem Yes light userdata Menu item handle.
isEnabled Yes boolean Pass true to enable menu item, false to disable it.

Example

genmenu.EnableMenuItem(hMenuItem, false)

CheckMenuItem

Checks/unchecks menu item.

Parameters

Parameter name Required Type Description
hMenuItem Yes light userdata Menu item handle.
isChecked Yes boolean Pass true to check menu item, false to uncheck it.

Example

genmenu.CheckMenuItem(hMenuItem, true)

RemoveMenuItem

Removes menu item.

Parameters

Parameter name Required Type Description
hMenuItem Yes light userdata Menu item handle.

Result

     Type: boolean

     Returns true on success, otherwise false.

Example

genmenu.RemoveMenuItem(hMenuItem)

Structures

MenuItem

A table describing menu parameters.

Fields

Field name Required Type Description
Name Yes string Menu item name (automatically translated by Core).
Uid No string Plugin UUID in format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
Service No string Service name.
Position No number Menu item position.
Parent No light userdata Parent menu handle.
Icon No light userdata Icon handle.
Flags No number Additional flags.