summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-01 18:18:24 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-01 18:18:24 +0000
commit84a403f0a0590ebc11f66955e864c12886da5815 (patch)
tree628d49ac79ea159ba0109eb8817cfd9144dbab13 /src/gui
parente02192d7d1a34088d66072a60cf3ed57d638a695 (diff)
downloadMana-84a403f0a0590ebc11f66955e864c12886da5815.tar.gz
Mana-84a403f0a0590ebc11f66955e864c12886da5815.tar.bz2
Mana-84a403f0a0590ebc11f66955e864c12886da5815.tar.xz
Mana-84a403f0a0590ebc11f66955e864c12886da5815.zip
Chat input now hides when not focussed, and doesn't allow player be controlled
by keyboard when it is.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp8
-rw-r--r--src/gui/chat.h4
-rw-r--r--src/gui/chatinput.cpp35
-rw-r--r--src/gui/chatinput.h47
4 files changed, 90 insertions, 4 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 380d9d13..40a44b13 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -24,6 +24,7 @@
#include "chat.h"
#include "textfield.h"
#include "textbox.h"
+#include "chatinput.h"
#include "../graphics.h"
#include "../main.h"
#include <iostream>
@@ -37,7 +38,7 @@ ChatWindow::ChatWindow(const char *logfile, int item_num):
setContentSize(600, 100);
textOutput = new TextBox();
- chatInput = new TextField();
+ chatInput = new ChatInput();
textOutput->setEditable(false);
scrollArea = new ScrollArea(textOutput);
scrollArea->setDimension(gcn::Rectangle(
@@ -228,13 +229,16 @@ void ChatWindow::action(const std::string& eventId)
chatInput->setText("");
}
+ // Remove focus and hide input
gui->focusNone();
+ chatInput->setVisible(false);
}
}
-void ChatWindow::requestFocus()
+void ChatWindow::requestChatFocus()
{
// Give focus to the chat input
+ chatInput->setVisible(true);
chatInput->requestFocus();
}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 4b0946f9..1c3fc007 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -138,9 +138,9 @@ class ChatWindow : public Window, public gcn::ActionListener,
void action(const std::string &actionId);
/**
- * Request focus.
+ * Request focus for typing chat message.
*/
- void requestFocus();
+ void requestChatFocus();
/**
* Checks whether ChatWindow is Focused or not.
diff --git a/src/gui/chatinput.cpp b/src/gui/chatinput.cpp
new file mode 100644
index 00000000..55417ac8
--- /dev/null
+++ b/src/gui/chatinput.cpp
@@ -0,0 +1,35 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "chatinput.h"
+
+ChatInput::ChatInput()
+{
+ setVisible(false);
+}
+
+void ChatInput::lostFocus()
+{
+ // TODO: Never mind this, it'll probably work in next Guichan version.
+ //setVisible(false);
+}
diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h
new file mode 100644
index 00000000..9f543e24
--- /dev/null
+++ b/src/gui/chatinput.h
@@ -0,0 +1,47 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_CHATINPUT_H
+#define _TMW_CHATINPUT_H
+
+#include "textfield.h"
+
+/**
+ * The chat input hides when it loses focus. It is also invisible by default.
+ */
+class ChatInput : public TextField
+{
+ public:
+ /**
+ * Constructor.
+ */
+ ChatInput();
+
+ /**
+ * Called if the chat input loses focus. It will set itself to
+ * invisible as result.
+ */
+ void lostFocus();
+};
+
+#endif