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

From Miranda NG
Jump to navigation Jump to search
(make it translatable)
(transform 'HotkeyItem' structure fields into table)
Line 122: Line 122:


==== {{Ls|MirLua/Modules/fields}} ====
==== {{Ls|MirLua/Modules/fields}} ====
: '''''Name'''''
{| class="wikitable"
:: Type: '''string'''
|-
:: Name of key combination (automatically translated by Core).
! scope="col" | {{Ls|MirLua/Modules/field_name}}
: ''Description''
! scope="col" | {{Ls|MirLua/Modules/required_param}}
:: Type: '''string'''
! scope="col" | {{Ls|Content/TableHeaders/type}}
:: Description of key combination (automatically translated by Core).
! scope="col" | {{Ls|Content/TableHeaders/description}}
: ''Section''
|-
:: Type: '''string'''
! scope="row" class="MirLuaParametersTable-parameter" | Name
:: Section name in Miranda hotkey settings. By default plugin name (''MirLua'') is used.
| style="text-align:center" | {{Ls|YesNo/yes}}
: ''Hotkey''
| style="text-align:center" | <code>string</code>
:: Type: '''number'''
| <translate>Name of key combination (automatically translated by Core).</translate>
:: Default [[Plugin:MirLua/en/m_hotkeys#MakeHotkey|key combination]].
|-
: ''Service''
! scope="row" class="MirLuaParametersTable-parameter" | Description
:: Type: '''string'''
| style="text-align:center" | {{Ls|YesNo/no}}
:: [[Plugin:MirLua/en/m_core#CreateServiceFunction|Service]] name.
| style="text-align:center" | <code>string</code>
: ''Flags''
| <translate>Description of key combination (automatically translated by Core).</translate>
:: Type: '''number'''
|-
:: Additional flags.
! scope="row" class="MirLuaParametersTable-parameter" | Section
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>string</code>
| <translate>Section name in Miranda hotkey settings. By default plugin name (<tvar|MirLua>MirLua</>) is used.</translate>
|-
! scope="row" class="MirLuaParametersTable-parameter" | Hotkey
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>number</code>
| <translate>Default [[<tvar|link>#MakeHotkey</>|key combination]].</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" | Flags
| style="text-align:center" | {{Ls|YesNo/no}}
| style="text-align:center" | <code>number</code>
| <translate>Additional flags.</translate>
|}

Revision as of 19:05, 2 June 2018

Other languages:

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:
  • shift = 0x01
  • control = 0x02
  • alt = 0x04
  • win = 0x08
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

Field name Required Type Description
Name Yes string Name of key combination (automatically translated by Core).
Description No string Description of key combination (automatically translated by Core).
Section No string Section name in Miranda hotkey settings. By default plugin name (MirLua) is used.
Hotkey No number Default key combination.
Service No string Service name.
Flags No number Additional flags.