register key hander
This commit is contained in:
parent
46f5034030
commit
3db5673e70
|
@ -27,20 +27,18 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||||
}
|
}
|
||||||
|
|
||||||
// configure events' user commands
|
// configure events' user commands
|
||||||
if (enable_click) {
|
|
||||||
|
bool hasEvent = std::find_if(eventMap_.cbegin(), eventMap_.cend(),
|
||||||
|
[&config](const auto& eventEntry) {
|
||||||
|
return config[eventEntry.second].isString();
|
||||||
|
}) != eventMap_.cend();
|
||||||
|
|
||||||
|
if (enable_click || hasEvent) {
|
||||||
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
||||||
event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, &AModule::handleToggle));
|
event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, &AModule::handleToggle));
|
||||||
} else {
|
// register key release
|
||||||
std::map<std::pair<uint, GdkEventType>, std::string>::const_iterator it{eventMap_.cbegin()};
|
event_box_.add_events(Gdk::BUTTON_RELEASE_MASK);
|
||||||
while (it != eventMap_.cend()) {
|
event_box_.signal_button_release_event().connect(sigc::mem_fun(*this, &AModule::handleToggle));
|
||||||
if (config_[it->second].isString()) {
|
|
||||||
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
|
||||||
event_box_.signal_button_press_event().connect(
|
|
||||||
sigc::mem_fun(*this, &AModule::handleToggle));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (config_["on-scroll-up"].isString() || config_["on-scroll-down"].isString() || enable_scroll) {
|
if (config_["on-scroll-up"].isString() || config_["on-scroll-down"].isString() || enable_scroll) {
|
||||||
event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
|
event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
|
||||||
|
|
Loading…
Reference in New Issue