summaryrefslogtreecommitdiff
path: root/src/gui/widgets/textfield.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-30 16:16:09 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-30 16:16:09 +0300
commit6e6fd65992343ca37e92d24efc760666b4485160 (patch)
treecfefd917c2b33694e93902c4b96030c300ae16a0 /src/gui/widgets/textfield.cpp
parent6e5d8181b830694a90bba7ad5651fa0b726e4a75 (diff)
downloadmanaverse-6e6fd65992343ca37e92d24efc760666b4485160.tar.gz
manaverse-6e6fd65992343ca37e92d24efc760666b4485160.tar.bz2
manaverse-6e6fd65992343ca37e92d24efc760666b4485160.tar.xz
manaverse-6e6fd65992343ca37e92d24efc760666b4485160.zip
Allow open context menu in textfields before connecting to server.
Diffstat (limited to 'src/gui/widgets/textfield.cpp')
-rw-r--r--src/gui/widgets/textfield.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 3a6212b79..950bba025 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -26,6 +26,7 @@
#include "configuration.h"
#include "keyevent.h"
+#include "gui/popupmenu.h"
#include "gui/sdlinput.h"
#include "gui/viewport.h"
@@ -58,7 +59,8 @@ TextField::TextField(const Widget2 *const widget,
mLoseFocusOnTab(loseFocusOnTab),
mLastEventPaste(false),
mPadding(1),
- mCaretColor(&getThemeColor(Theme::CARET))
+ mCaretColor(&getThemeColor(Theme::CARET)),
+ mPopupMenu(nullptr)
{
setFrameSize(2);
mForegroundColor = getThemeColor(Theme::TEXTFIELD);
@@ -90,6 +92,9 @@ TextField::TextField(const Widget2 *const widget,
TextField::~TextField()
{
+ delete mPopupMenu;
+ mPopupMenu = nullptr;
+
instances--;
if (instances == 0)
{
@@ -522,7 +527,21 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent)
if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
{
if (viewport)
+ {
viewport->showTextFieldPopup(this);
+ }
+ else
+ {
+ if (!mPopupMenu)
+ mPopupMenu = new PopupMenu();
+ int x = 0;
+ int y = 0;
+ SDL_GetMouseState(&x, &y);
+ mPopupMenu->showTextFieldPopup(x, y, this);
+ }
+ }
+ else
+ {
+ gcn::TextField::mousePressed(mouseEvent);
}
- else gcn::TextField::mousePressed(mouseEvent);
}