diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-13 12:28:04 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-13 12:28:04 +0100 |
commit | f1ba2a5607f23ed0b23d74240ea66cb1f8d2c1ad (patch) | |
tree | 00d7374c90d3c9bd97de4dbc75650b4d6d9e8c9b /src/crepe | |
parent | ab69e41cabd6f5a84ebb2e2629d194b49b7039de (diff) |
tested channel and deactivating in function
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/api/IKeyListener.cpp | 3 | ||||
-rw-r--r-- | src/crepe/api/IMouseListener.cpp | 6 | ||||
-rw-r--r-- | src/crepe/api/IMouseListener.h | 4 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/crepe/api/IKeyListener.cpp b/src/crepe/api/IKeyListener.cpp index 17d8735..e759eca 100644 --- a/src/crepe/api/IKeyListener.cpp +++ b/src/crepe/api/IKeyListener.cpp @@ -41,5 +41,8 @@ void IKeyListener::deactivate_keys() { this->unsubscribe_events(); } void IKeyListener::set_channel(int channel){ + this->unsubscribe_events(); this->channel = channel; + this->subscribe_events(); + } diff --git a/src/crepe/api/IMouseListener.cpp b/src/crepe/api/IMouseListener.cpp index 68061be..c6ea419 100644 --- a/src/crepe/api/IMouseListener.cpp +++ b/src/crepe/api/IMouseListener.cpp @@ -35,18 +35,20 @@ void IMouseListener::unsubscribe_events() { EventManager::get_instance().unsubscribe<MouseReleaseEvent>(this->mouse_release_handler, this->channel); EventManager::get_instance().unsubscribe<MouseMoveEvent>(this->mouse_move_handler, this->channel); } -void IMouseListener::activate_keys() { +void IMouseListener::activate_mouse() { if(this->active){ return; } this->subscribe_events(); } -void IMouseListener::deactivate_keys() { +void IMouseListener::deactivate_mouse() { if(!this->active){ return; } this->unsubscribe_events(); } void IMouseListener::set_channel(int channel){ + this->unsubscribe_events(); this->channel = channel; + this->subscribe_events(); } diff --git a/src/crepe/api/IMouseListener.h b/src/crepe/api/IMouseListener.h index 4493e7f..a7ad271 100644 --- a/src/crepe/api/IMouseListener.h +++ b/src/crepe/api/IMouseListener.h @@ -77,12 +77,12 @@ public: /** * \brief Activates mouse listening. */ - void activate_keys(); + void activate_mouse(); /** * \brief Deactivates mouse listening. */ - void deactivate_keys(); + void deactivate_mouse(); /** * \brief Sets the channel ID for event handling. |