New module: Platform - Split window management from Utility module (#128)
* New module: Platform - Split window management from Utility module Final touch * NDK/SDK: Bring back initialization of Utility
This commit is contained in:
committed by
Jérôme Leclercq
parent
41a1b5d493
commit
5aa072cee3
39
tests/Engine/Platform/EventHandler/TextEnterState.cpp
Normal file
39
tests/Engine/Platform/EventHandler/TextEnterState.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "TextEnterState.hpp"
|
||||
|
||||
#include "StateContext.hpp"
|
||||
#include "StateFactory.hpp"
|
||||
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
TextEnterState::TextEnterState(StateContext& context) :
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEnterState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
{
|
||||
if (key.code == Nz::Keyboard::Key::M && key.shift)
|
||||
{
|
||||
fsm.ChangeState(StateFactory::Get(EventStatus::Menu));
|
||||
}
|
||||
});
|
||||
|
||||
m_textEnteredSlot.Connect(eventHandler.OnTextEntered, [&] (const Nz::EventHandler*, const Nz::WindowEvent::TextEvent& event)
|
||||
{
|
||||
Nz::String content = "Character: " + Nz::String::Unicode(event.character);
|
||||
if (event.repeated)
|
||||
content += " repeated";
|
||||
m_text.SetContent(content + "\nM for Menu");
|
||||
});
|
||||
}
|
||||
|
||||
void TextEnterState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Enter some text, this text should change !\nM for Menu");
|
||||
}
|
||||
Reference in New Issue
Block a user