mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-16 20:39:15 +01:00
Add typing listener (to store strings), deregister listeners on delete
This commit is contained in:
parent
aa0d8246bb
commit
0a3bc3e081
@ -1,5 +1,15 @@
|
||||
#include "menu.hh"
|
||||
|
||||
class KeyboardTypingListener : public StringListener
|
||||
{
|
||||
virtual void stringCallback(const char *str)
|
||||
{
|
||||
printf("string: %s\n", str);
|
||||
/* Remove thyself! */
|
||||
delete this;
|
||||
}
|
||||
};
|
||||
|
||||
class MainView;
|
||||
class MainMenu : public Menu, KeyListener
|
||||
{
|
||||
@ -75,6 +85,8 @@ public:
|
||||
Gui::gui->pushView(Gui::gui->kv);
|
||||
Gui::gui->kv->activate();
|
||||
Gui::gui->kv->registerKeyListener(this);
|
||||
if (this->p_submenus[2].sel == 0)
|
||||
Gui::gui->kv->registerStringListener(new KeyboardTypingListener());
|
||||
break;
|
||||
|
||||
case 11:
|
||||
|
@ -376,3 +376,14 @@ void VirtualKeyboard::updateTheme()
|
||||
|
||||
/* The singleton */
|
||||
VirtualKeyboard *VirtualKeyboard::kbd;
|
||||
|
||||
|
||||
KeyListener::~KeyListener()
|
||||
{
|
||||
VirtualKeyboard::kbd->unregisterKeyListener(this);
|
||||
}
|
||||
|
||||
StringListener::~StringListener()
|
||||
{
|
||||
VirtualKeyboard::kbd->unregisterStringListener(this);
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ struct virtkey;
|
||||
class KeyListener
|
||||
{
|
||||
public:
|
||||
~KeyListener();
|
||||
|
||||
/* Each key is a string */
|
||||
virtual void keyCallback(bool shift, const char *str) = 0;
|
||||
};
|
||||
@ -30,6 +32,8 @@ public:
|
||||
class StringListener
|
||||
{
|
||||
public:
|
||||
~StringListener();
|
||||
|
||||
virtual void stringCallback(const char *str) = 0;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user