Plugin:MirLua/Module/m hotkeys: Difference between revisions
Jump to navigation
Jump to search
m (Goraf moved page Plugin:MirLua/Module/m hotkeys to Plugin:MirLua/Module/m hotkeys: to transform to translation system) |
(make it translatable) |
||
Line 1: | Line 1: | ||
<languages/> | |||
<translate> | |||
Allows you to work with key combinations. | Allows you to work with key combinations. | ||
</translate> | |||
{{Ls|MirLua/Modules/include_info}} <code>local hotkeys = require('m_hotkeys')</code> | |||
__TOC__ | __TOC__ | ||
<translate> | |||
== Functions == | == Functions == | ||
</translate> | |||
=== Register === | === Register === | ||
Registers a key combination. | <translate>Registers a key combination.</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" | data | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>table</code> | |||
| <translate><tvar|HotkeyItem>[[#HotkeyItem|HotkeyItem]]</> table.</translate> | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}} <code>boolean</code> | |||
{{nbsp|5}}<translate>Returns <tvar|true><code>true</code></> if key combination was registered successfully, otherwise <tvar|false><code>false</code></>.</translate> | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code= | {{Content:MirLua/Example|code= | ||
local hIcon = hotkeys.Register({ Name = 'hkUniqueName' }) | local hIcon = hotkeys.Register({ Name = 'hkUniqueName' }) | ||
}} | }} | ||
---- | |||
=== Unregister === | === Unregister === | ||
Removes a key combination. | <translate>Removes a key combination.</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" | name | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| <translate>Key combination name.</translate> | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}} <code>boolean</code> | |||
{{nbsp|5}}<translate>Returns <tvar|true><code>true</code></> if key combination was removed successfully, otherwise <tvar|false><code>false</code></>.</translate> | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code= | {{Content:MirLua/Example|code= | ||
hotkeys.Unregister('hkUniqueName') | hotkeys.Unregister('hkUniqueName') | ||
}} | }} | ||
---- | |||
=== MakeHotkey === | === MakeHotkey === | ||
Creates key combination. | <translate>Creates key combination.</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" | modifier | ||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>number</code>, <code>string</code>, <code>table</code> | |||
| <translate>Modifier key code or name or list of names. Takes values:</translate> | |||
* shift = 0x01 | |||
* control = 0x02 | |||
* alt = 0x04 | |||
* win = 0x08 | |||
|- | |||
! scope="row" class="MirLuaParametersTable-parameter" | key | |||
| style="text-align:center" | {{Ls|YesNo/yes}} | |||
| style="text-align:center" | <code>string</code> | |||
| <translate>Normal (non-modifier) key.</translate> | |||
|} | |||
==== {{Ls|MirLua/Modules/result}} ==== | |||
{{nbsp|5}}{{Ls|MirLua/Modules/type}} <code>number</code> | |||
{{nbsp|5}}<translate>Returns key combination.</translate> | |||
==== {{Ls|MirLua/Modules/example}} ==== | |||
{{Content:MirLua/Example|code= | {{Content:MirLua/Example|code= | ||
local HOTKEYF_SHIFT = 0x01 | local HOTKEYF_SHIFT = 0x01 | ||
Line 61: | Line 106: | ||
}} | }} | ||
{{Content:MirLua/Example|code= | |||
local hk = hotkeys.MakeHotkey('ctrl', 'A') | |||
}} | |||
{{Content:MirLua/Example|code= | |||
local hk = hotkeys.MakeHotkey({ 'ctrl', 'alt' }, 'A') | |||
}} | |||
<translate> | |||
== Structures == | == Structures == | ||
</translate> | |||
=== HotkeyItem === | === HotkeyItem === | ||
A table describing key combination parameters. | <translate>A table describing key combination parameters.</translate> | ||
==== {{Ls|MirLua/Modules/fields}} ==== | |||
: '''''Name''''' | : '''''Name''''' | ||
:: Type: '''string''' | :: Type: '''string''' | ||
Line 84: | Line 140: | ||
:: Type: '''number''' | :: Type: '''number''' | ||
:: Additional flags. | :: Additional flags. | ||
Revision as of 18:46, 2 June 2018
Allows you to work with key combinations.
Include module: local hotkeys = require('m_hotkeys')
Functions
Register
Registers a key combination.
Parameters
Parameter name | Required | Type | Description |
---|---|---|---|
data | Yes | table
|
HotkeyItem table. |
Result
Type: boolean
Returns true
if key combination was registered successfully, otherwise false
.
Example
local hIcon = hotkeys.Register({ Name = 'hkUniqueName' })
Unregister
Removes a key combination.
Parameters
Parameter name | Required | Type | Description |
---|---|---|---|
name | Yes | string
|
Key combination name. |
Result
Type: boolean
Returns true
if key combination was removed successfully, otherwise false
.
Example
hotkeys.Unregister('hkUniqueName')
MakeHotkey
Creates key combination.
Parameters
Parameter name | Required | Type | Description |
---|---|---|---|
modifier | Yes | number , string , table
|
Modifier key code or name or list of names. Takes values:
|
key | Yes | string
|
Normal (non-modifier) key. |
Result
Type: number
Returns key combination.
Example
local HOTKEYF_SHIFT = 0x01
local HOTKEYF_ALT = 0x04
local hk = hotkeys.MakeHotkey(HOTKEYF_SHIFT | HOTKEYF_ALT, 'A')
local hk = hotkeys.MakeHotkey('ctrl', 'A')
local hk = hotkeys.MakeHotkey({ 'ctrl', 'alt' }, 'A')
Structures
HotkeyItem
A table describing key combination parameters.
Fields
- Name
- Type: string
- Name of key combination (automatically translated by Core).
- Description
- Type: string
- Description of key combination (automatically translated by Core).
- Section
- Type: string
- Section name in Miranda hotkey settings. By default plugin name (MirLua) is used.
- Hotkey
- Type: number
- Default key combination.
- Service
- Type: string
- Service name.
- Flags
- Type: number
- Additional flags.