From ce16e029ed4db207894bc334eb1a00438739d8d2 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Wed, 1 Mar 2023 23:39:36 +0300 Subject: [PATCH] Issue #2030. AModule enable_click & enable_scroll Signed-off-by: Viktar Lukashonak --- src/AModule.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/AModule.cpp b/src/AModule.cpp index 1566e88b..459e5620 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -12,6 +12,20 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: config_(std::move(config)), distance_scrolled_y_(0.0), distance_scrolled_x_(0.0) { + // Configure module action Map + const Json::Value actions{config_["actions"]}; + for (Json::Value::const_iterator it = actions.begin(); it != actions.end(); ++it) { + if (it.key().isString() && it->isString()) + if (eventActionMap_.count(it.key().asString()) == 0) { + eventActionMap_.insert({it.key().asString(), it->asString()}); + enable_click = true; + enable_scroll = true; + } else + spdlog::warn("Dublicate action is ignored: {0}", it.key().asString()); + else + spdlog::warn("Wrong actions section configuration. See config by index: {}", it.index()); + } + // configure events' user commands if (enable_click) { event_box_.add_events(Gdk::BUTTON_PRESS_MASK); @@ -32,18 +46,6 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std:: event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK); event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, &AModule::handleScroll)); } - - // Configure module action Map - const Json::Value actions{config_["actions"]}; - for (Json::Value::const_iterator it = actions.begin(); it != actions.end(); ++it) { - if (it.key().isString() && it->isString()) - if (eventActionMap_.count(it.key().asString()) == 0) - eventActionMap_.insert({it.key().asString(), it->asString()}); - else - spdlog::warn("Dublicate action is ignored: {0}", it.key().asString()); - else - spdlog::warn("Wrong actions section configuration. See config by index: {}", it.index()); - } } AModule::~AModule() {