From 5df8202ad60be761df03317bee3c1003b5692463 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Thu, 22 Sep 2016 21:31:41 +0200 Subject: [PATCH] Make TextureEditingState responsible for TextureEditor key events --- src/Application/States/TextureMappingState.cpp | 6 ++++++ src/Application/States/TextureMappingState.h | 1 + src/UserInterface/TextureEditor.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Application/States/TextureMappingState.cpp b/src/Application/States/TextureMappingState.cpp index cc62a3d..3548d9d 100644 --- a/src/Application/States/TextureMappingState.cpp +++ b/src/Application/States/TextureMappingState.cpp @@ -61,6 +61,8 @@ void TextureMappingState::draw(Application * app){ } void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ + app->getGui()->getTextureEditor()->keyPressed(args); + switch(args.key){ case '>': @@ -108,6 +110,10 @@ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) } } +void TextureMappingState::onKeyReleased(Application * app, ofKeyEventArgs & args){ + app->getGui()->getTextureEditor()->keyReleased(args); +} + void TextureMappingState::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){ // Exec the command only if a joint is selected. bool selected = false; diff --git a/src/Application/States/TextureMappingState.h b/src/Application/States/TextureMappingState.h index 275226f..a78dbb9 100644 --- a/src/Application/States/TextureMappingState.h +++ b/src/Application/States/TextureMappingState.h @@ -25,6 +25,7 @@ class TextureMappingState : public ApplicationBaseState { void update(Application * app); void draw(Application * app); void onKeyPressed(Application * app, ofKeyEventArgs & args); + void onKeyReleased(Application * app, ofKeyEventArgs & args); void onBackgroundPressed(Application * app, GuiBackgroundEvent & e); void onMousePressed(Application * app, ofMouseEventArgs & args); void onMouseReleased(Application * app, ofMouseEventArgs & args); diff --git a/src/UserInterface/TextureEditor.cpp b/src/UserInterface/TextureEditor.cpp index 9e2b608..ae9b968 100644 --- a/src/UserInterface/TextureEditor.cpp +++ b/src/UserInterface/TextureEditor.cpp @@ -14,13 +14,13 @@ TextureEditor::~TextureEditor(){ } void TextureEditor::registerKeyEvents(){ - ofAddListener(ofEvents().keyPressed, this, &TextureEditor::keyPressed); - ofAddListener(ofEvents().keyReleased, this, &TextureEditor::keyReleased); + //ofAddListener(ofEvents().keyPressed, this, &TextureEditor::keyPressed); + //ofAddListener(ofEvents().keyReleased, this, &TextureEditor::keyReleased); } void TextureEditor::unregisterKeyEvents(){ - ofRemoveListener(ofEvents().keyPressed, this, &TextureEditor::keyPressed); - ofRemoveListener(ofEvents().keyReleased, this, &TextureEditor::keyReleased); + //ofRemoveListener(ofEvents().keyPressed, this, &TextureEditor::keyPressed); + //ofRemoveListener(ofEvents().keyReleased, this, &TextureEditor::keyReleased); } void TextureEditor::enable(){