summaryrefslogtreecommitdiff
path: root/src/guiKeyChangeMenu.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-09-01 18:02:29 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-09-01 18:03:50 +0300
commit5194505407884f6375311f0ab4c5f8783646cb91 (patch)
treea3457cf11bdf0f3203d5e5313020ffba0e50ea1c /src/guiKeyChangeMenu.cpp
parent3e7957512bdb86acb3836c6c1df96e38e05efa3c (diff)
downloadminetest-5194505407884f6375311f0ab4c5f8783646cb91.tar.gz
minetest-5194505407884f6375311f0ab4c5f8783646cb91.tar.bz2
minetest-5194505407884f6375311f0ab4c5f8783646cb91.zip
Fix GUIKeyChangeMenu so that '/' can be inserted on a finnish keyboard
Diffstat (limited to 'src/guiKeyChangeMenu.cpp')
-rw-r--r--src/guiKeyChangeMenu.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp
index a7dbc8c6f..49b292df4 100644
--- a/src/guiKeyChangeMenu.cpp
+++ b/src/guiKeyChangeMenu.cpp
@@ -60,6 +60,7 @@ GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
GUIModalMenu(env, parent, id, menumgr)
{
+ shift_down = false;
activeKey = -1;
this->key_used_text = NULL;
init_keys();
@@ -204,7 +205,15 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
&& event.KeyInput.PressedDown)
{
changeCtype("");
- KeyPress kp(event.KeyInput);
+ bool prefer_character = shift_down;
+ KeyPress kp(event.KeyInput, prefer_character);
+
+ bool shift_went_down = false;
+ if(!shift_down &&
+ (event.KeyInput.Key == irr::KEY_SHIFT ||
+ event.KeyInput.Key == irr::KEY_LSHIFT ||
+ event.KeyInput.Key == irr::KEY_RSHIFT))
+ shift_went_down = true;
// Remove Key already in use message
if(this->key_used_text)
@@ -240,8 +249,14 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
this->key_used.push_back(kp);
changeCtype("C");
- activeKey = -1;
- return true;
+ // Allow characters made with shift
+ if(shift_went_down){
+ shift_down = true;
+ return false;
+ }else{
+ activeKey = -1;
+ return true;
+ }
}
}
if (event.EventType == EET_GUI_EVENT)
@@ -287,6 +302,7 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
assert(k);
resetMenu();
+ shift_down = false;
activeKey = event.GUIEvent.Caller->getID();
k->button->setText(wgettext("press key"));
this->key_used.erase(std::remove(this->key_used.begin(),