scim::HotkeyMatcher Class Reference
Accessories

This class is used to match a KeyEvent among a set of hotkeys. More...

`#include <scim_hotkey.h>`

## Public Member Functions

| HotkeyMatcher ()
| Constructor.
| ~HotkeyMatcher ()
| Destructor.
void | add_hotkey (const KeyEvent &key, int id)
| Add a Hotkey into this HotkeyMatcher.
void | add_hotkeys (const KeyEventList &keys, int id)
| Add a set of Hotkeys into this HotkeyMatcher.
size_t | find_hotkeys (int id, KeyEventList &keys) const
| Find all Hotkeys binded to a specific id.
size_t | get_all_hotkeys (KeyEventList &keys, std::vector< int > &ids) const
| Get all Hotkeys added into this HotkeyMatcher.
void | reset (void)
| Reset the HotkeyMatcher.
void | clear (void)
| Clear all Hotkeys.
void | push_key_event (const KeyEvent &key)
| Push a KeyEvent into the queue.
bool | is_matched (void) const
| Check if the last KeyEvent pushed by push_key_event () matched with any Hotkey.
int | get_match_result (void) const
| Get the match result.

## Detailed Description

This class is used to match a KeyEvent among a set of hotkeys.

This class keeps the key event history so that it can match any kind of key events, including key release events, correctly.

If there are large amount of hotkeys to be matched, this class can provide very good performance.

## Constructor & Destructor Documentation

## HotkeyMatcher()

scim::HotkeyMatcher::HotkeyMatcher | ( |  | ) |

Constructor.

## ~HotkeyMatcher()

scim::HotkeyMatcher::~HotkeyMatcher | ( |  | ) |

Destructor.

## Member Function Documentation

## add_hotkey()

void scim::HotkeyMatcher::add_hotkey | ( | const KeyEvent & | key,
|  | int | id )

Add a Hotkey into this HotkeyMatcher.

If a same Hotkey was already added, then it'll be replaced by this new one.

Parameters

  key | A Hotkey to be added.
  id | An id to be binded to this Hotkey.

## add_hotkeys()

void scim::HotkeyMatcher::add_hotkeys | ( | const KeyEventList & | keys,
|  | int | id )

Add a set of Hotkeys into this HotkeyMatcher.

If a same Hotkey in the list was already added, then it'll be replaced by the new one.

Parameters

  keys | A set of Hotkeys to be added.
  id | An id to be binded to these Hotkeys.

## find_hotkeys()

size_t scim::HotkeyMatcher::find_hotkeys | ( | int | id,
|  | KeyEventList & | keys ) const

Find all Hotkeys binded to a specific id.

Parameters

  id | The id to be found.
  keys | A KeyEventList object to hold all KeyEvents binded to the id.

Returns
  The number of Hotkeys found.

## get_all_hotkeys()

size_t scim::HotkeyMatcher::get_all_hotkeys | ( | KeyEventList & | keys,
|  | std::vector< int > & | ids ) const

Get all Hotkeys added into this HotkeyMatcher.

Parameters

  keys | A KeyEventList object to hold all KeyEvents.
  ids | A int list to hold all corresponding IDs.

Returns
  The number of available Hotkeys.

## reset()

void scim::HotkeyMatcher::reset | ( | void |  | ) |

Reset the HotkeyMatcher.

The KeyEvent queue will be cleared, all state will be reset. The Hotkeys which were already added will not be touched.

## clear()

void scim::HotkeyMatcher::clear | ( | void |  | ) |

Clear all Hotkeys.

## push_key_event()

void scim::HotkeyMatcher::push_key_event | ( | const KeyEvent & | key | ) |

Push a KeyEvent into the queue.

This KeyEvent will be matched against the available Hotkeys immediately.

Parameters

  key | The key to be pushed into.

## is_matched()

bool scim::HotkeyMatcher::is_matched | ( | void |  | ) | const

Check if the last KeyEvent pushed by push_key_event () matched with any Hotkey.

Returns
  true If the KeyEvent matched with a Hotkey.

## get_match_result()

int scim::HotkeyMatcher::get_match_result | ( | void |  | ) | const

Get the match result.

Returns
  The corresponding id of the matched Hotkey. If no Hotkey was matched, return -1.

The documentation for this class was generated from the following file:

- scim_hotkey.h