cwidget
0.5.17
|
Stores the keys bound to various functions. More...
#include <keybindings.h>
Public Member Functions | |
keybindings (keybindings *_parent=NULL) | |
Create a new key-binding scope. More... | |
std::wstring | keyname (const std::string &tag) |
std::wstring | readable_keyname (const std::string &tag) |
keybinding | get (std::string tag) |
Retrieve the binding of the given function. More... | |
void | set (std::string tag, keybinding strokes) |
Modify a binding in this scope. More... | |
void | set (std::string tag, const key &stroke) |
Modify a binding in this scope. More... | |
bool | key_matches (const key &k, std::string tag) |
Test whether a key is bound to a function. More... | |
Stores the keys bound to various functions.
Functions are simply arbitrary strings chosen by the user of this class. For instance, "QuitProgram" might be the function that quits the program.
Each keybindings object represents a scope in which bindings can be defined. Scopes are arranged hierarchically, and the bindings defined in child scopes override the bindings defined in parent scopes.
|
inline |
Create a new key-binding scope.
_parent | The parent of this scope, if any, or NULL for no parent. |
References cwidget::config::keyname(), and cwidget::config::readable_keyname().
|
inline |
Retrieve the binding of the given function.
Test whether a key is bound to a function.
k | The key to test. |
tag | The function to test against. |
References KEY_CTRL, and cwidget::config::parse_key().
Referenced by cwidget::widgets::text_layout::handle_key(), cwidget::widgets::menubar::handle_key(), cwidget::widgets::menu::handle_key(), and cwidget::toplevel::post_event().
wstring cwidget::config::keybindings::keyname | ( | const std::string & | tag | ) |
tag | The function whose keystroke is to be returned. |
wstring cwidget::config::keybindings::readable_keyname | ( | const std::string & | tag | ) |
tag | The name of the function whose keystroke is to be returned. |
Referenced by cwidget::widgets::menu::paint(), and cwidget::widgets::menu::width_request().
void cwidget::config::keybindings::set | ( | std::string | tag, |
keybinding | strokes | ||
) |
Modify a binding in this scope.
tag | The name of the function to be bound. |
strokes | The keystrokes to bind to the function. |
This routine throws away any previous bindings for the given function and replaces them with the bindings stored in strokes.
Referenced by cwidget::toplevel::init().
|
inline |
Modify a binding in this scope.
tag | The name of the function to be bound. |
stroke | A keystroke to bind to the function. |
This routine throws away any previous bindings for the given function and replaces them with stroke.
References cwidget::config::global_bindings, cwidget::config::keyname(), and cwidget::config::readable_keyname().