summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Langley <joshlangley[at]optusnet.com.au>2007-08-19 17:10:53 +0000
committerJoshua Langley <joshlangley[at]optusnet.com.au>2007-08-19 17:10:53 +0000
commit1d9b37e81b1c91986644d6e9580422e6f8b47e25 (patch)
tree2a906d13678654f461760df3cff49808a4d27b05 /src
parent0c074ec10a70b20345bbc0169dad78fe17644e86 (diff)
downloadmana-1d9b37e81b1c91986644d6e9580422e6f8b47e25.tar.gz
mana-1d9b37e81b1c91986644d6e9580422e6f8b47e25.tar.bz2
mana-1d9b37e81b1c91986644d6e9580422e6f8b47e25.tar.xz
mana-1d9b37e81b1c91986644d6e9580422e6f8b47e25.zip
src/gui/setup_keyboard.cpp, src/gui/setup_keyboard.h: fixed bug - reverts unassigned key.
Diffstat (limited to 'src')
-rw-r--r--src/gui/setup_keyboard.cpp24
-rw-r--r--src/gui/setup_keyboard.h7
2 files changed, 28 insertions, 3 deletions
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 3cce3483..3c8c8163 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -70,7 +70,8 @@ class KeyListModel : public gcn::ListModel
Setup_Keyboard::Setup_Keyboard():
mKeyListModel(new KeyListModel()),
- mKeyList(new ListBox(mKeyListModel))
+ mKeyList(new ListBox(mKeyListModel)),
+ mKeySetting(false)
{
keyboard.setSetupKeyboard(this);
setOpaque(false);
@@ -108,6 +109,8 @@ Setup_Keyboard::~Setup_Keyboard()
void Setup_Keyboard::apply()
{
+ keyUnresolved();
+
if (keyboard.hasConflicts())
{
new OkDialog("Key Conflict(s) Detected.",
@@ -119,8 +122,11 @@ void Setup_Keyboard::apply()
void Setup_Keyboard::cancel()
{
+ keyUnresolved();
+
keyboard.retrieve();
keyboard.setEnabled(true);
+
refreshKeys();
}
@@ -128,13 +134,16 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event)
{
if (event.getSource() == mKeyList)
{
- mAssignKeyButton->setEnabled(true);
+ if (!mKeySetting) {
+ mAssignKeyButton->setEnabled(true);
+ }
}
else if (event.getId() == "assign")
{
- int i(mKeyList->getSelected());
+ mKeySetting = true;
mAssignKeyButton->setEnabled(false);
keyboard.setEnabled(false);
+ int i(mKeyList->getSelected());
keyboard.setNewKeyIndex(i);
mKeyListModel->setElementAt(i, keyboard.getKeyCaption(i) + ": ?");
}
@@ -156,6 +165,7 @@ void Setup_Keyboard::refreshAssignedKey(int index)
void Setup_Keyboard::newKeyCallback(int index)
{
+ mKeySetting = false;
refreshAssignedKey(index);
mAssignKeyButton->setEnabled(true);
}
@@ -167,3 +177,11 @@ void Setup_Keyboard::refreshKeys()
refreshAssignedKey(i);
}
}
+
+void Setup_Keyboard::keyUnresolved()
+{
+ if (mKeySetting) {
+ newKeyCallback(keyboard.getNewKeyIndex());
+ keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE);
+ }
+}
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index ccc2558f..b72e8746 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -66,12 +66,19 @@ class Setup_Keyboard : public SetupTab, public gcn::ActionListener
*/
void refreshKeys();
+ /**
+ * If a key function is unresolved, then this reverts it.
+ */
+ void keyUnresolved();
+
private:
class KeyListModel *mKeyListModel;
gcn::ListBox *mKeyList;
gcn::Button *mAssignKeyButton;
gcn::Button *mMakeDefaultButton;
+
+ bool mKeySetting; /**< flag to check if key being set. */
};
#endif