OpenTTD Source 20241224-master-gf74b0cf984
HotkeyList Struct Reference

List of hotkeys for a window. More...

#include <hotkeys.h>

Public Types

typedef EventState(* GlobalHotkeyHandlerFunc) (int hotkey)
 

Public Member Functions

 HotkeyList (const std::string &ini_group, const std::vector< Hotkey > &items, GlobalHotkeyHandlerFunc global_hotkey_handler=nullptr)
 
void Load (const IniFile &ini)
 Load HotkeyList from IniFile.
 
void Save (IniFile &ini) const
 Save HotkeyList to IniFile.
 
int CheckMatch (uint16_t keycode, bool global_only=false) const
 Check if a keycode is bound to something.
 

Data Fields

GlobalHotkeyHandlerFunc global_hotkey_handler
 

Private Member Functions

 HotkeyList (const HotkeyList &other)
 Dummy private copy constructor to prevent compilers from copying the structure, which fails due to _hotkey_lists.
 

Private Attributes

const std::string ini_group
 
std::vector< Hotkeyitems
 

Detailed Description

List of hotkeys for a window.

Definition at line 37 of file hotkeys.h.

Member Typedef Documentation

◆ GlobalHotkeyHandlerFunc

typedef EventState(* HotkeyList::GlobalHotkeyHandlerFunc) (int hotkey)

Definition at line 38 of file hotkeys.h.

Constructor & Destructor Documentation

◆ HotkeyList()

HotkeyList::HotkeyList ( const std::string &  ini_group,
const std::vector< Hotkey > &  items,
GlobalHotkeyHandlerFunc  global_hotkey_handler = nullptr 
)

Definition at line 261 of file hotkeys.cpp.

◆ ~HotkeyList()

HotkeyList::~HotkeyList ( )

Definition at line 268 of file hotkeys.cpp.

Member Function Documentation

◆ CheckMatch()

int HotkeyList::CheckMatch ( uint16_t  keycode,
bool  global_only = false 
) const

Check if a keycode is bound to something.

Parameters
keycodeThe keycode that was pressed
global_onlyLimit the search to hotkeys defined as 'global'.
Returns
The number of the matching hotkey or -1.

Definition at line 309 of file hotkeys.cpp.

References WKC_GLOBAL_HOTKEY.

Referenced by HandleKeypress(), and IsQuitKey().

◆ Load()

void HotkeyList::Load ( const IniFile ini)

Load HotkeyList from IniFile.

Parameters
iniIniFile to load from.

Definition at line 277 of file hotkeys.cpp.

References IniLoadFile::GetGroup(), IniGroup::GetItem(), ParseHotkeys(), and IniItem::value.

◆ Save()

void HotkeyList::Save ( IniFile ini) const

Save HotkeyList to IniFile.

Parameters
iniIniFile to save to.

Definition at line 294 of file hotkeys.cpp.

References IniLoadFile::GetOrCreateGroup(), IniGroup::GetOrCreateItem(), SaveKeycodes(), and IniItem::SetValue().

Field Documentation

◆ global_hotkey_handler

GlobalHotkeyHandlerFunc HotkeyList::global_hotkey_handler

Definition at line 48 of file hotkeys.h.

◆ ini_group

const std::string HotkeyList::ini_group
private

Definition at line 50 of file hotkeys.h.

◆ items

std::vector<Hotkey> HotkeyList::items
private

Definition at line 51 of file hotkeys.h.


The documentation for this struct was generated from the following files: