diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-03-03 07:48:55 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-03-03 08:16:36 -0700 |
commit | b1aef06ac85b1ed7db7725e50b2dbfcdfd1a0925 (patch) | |
tree | 1ef54acdb35f0ca8f63620773d4ee431ac2122bb | |
parent | 4f422bd50c51d812fb9e50f2610c2cd37ead8ef2 (diff) | |
download | mana-b1aef06ac85b1ed7db7725e50b2dbfcdfd1a0925.tar.gz mana-b1aef06ac85b1ed7db7725e50b2dbfcdfd1a0925.tar.bz2 mana-b1aef06ac85b1ed7db7725e50b2dbfcdfd1a0925.tar.xz mana-b1aef06ac85b1ed7db7725e50b2dbfcdfd1a0925.zip |
Connect to a server when it's double clicked
Reviewed-by: Bernd Wachter
-rw-r--r-- | src/gui/serverdialog.cpp | 18 | ||||
-rw-r--r-- | src/gui/serverdialog.h | 3 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index da95b6a1..44998bcc 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -169,6 +169,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mServersListModel = new ServersListModel(&mServers, this); mServersList = new ListBox(mServersListModel); + mServersList->addMouseListener(this); + ScrollArea *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -371,20 +373,30 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &) mPortField->setText(toString(myServer.port)); switch (myServer.type) { - case ServerInfo::UNKNOWN: - mTypeField->setSelected(2); - break; case ServerInfo::EATHENA: mTypeField->setSelected(0); break; case ServerInfo::MANASERV: mTypeField->setSelected(1); + default: + mTypeField->setSelected(2); + break; } setFieldsReadOnly(true); mDeleteButton->setEnabled(myServer.save); } +void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) +{ + if (mouseEvent.getClickCount() == 2 && + mouseEvent.getSource() == mServersList) + { + action(gcn::ActionEvent(mConnectButton, + mConnectButton->getActionEventId())); + } +} + void ServerDialog::logic() { { diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index 6a7091c2..3d7dca9d 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -32,6 +32,7 @@ #include <guichan/actionlistener.hpp> #include <guichan/keylistener.hpp> #include <guichan/listmodel.hpp> +#include <guichan/mouselistener.hpp> #include <guichan/selectionlistener.hpp> #include <string> @@ -134,6 +135,8 @@ class ServerDialog : public Window, */ void valueChanged(const gcn::SelectionEvent &event); + void mouseClicked(gcn::MouseEvent &mouseEvent); + void logic(); protected: |