summaryrefslogtreecommitdiff
path: root/src/gui/popupmenu.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-30 16:00:06 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-30 16:00:06 +0300
commit6e5d8181b830694a90bba7ad5651fa0b726e4a75 (patch)
tree27c2cc174c5b327a75604c1c99a270143879be7c /src/gui/popupmenu.cpp
parent8a24c37deef374bf138569d50221e34fbc97ee98 (diff)
downloadmanaverse-6e5d8181b830694a90bba7ad5651fa0b726e4a75.tar.gz
manaverse-6e5d8181b830694a90bba7ad5651fa0b726e4a75.tar.bz2
manaverse-6e5d8181b830694a90bba7ad5651fa0b726e4a75.tar.xz
manaverse-6e5d8181b830694a90bba7ad5651fa0b726e4a75.zip
Add popup menu for text fields.
This menu allow copy/paste text to/from clipboard.
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r--src/gui/popupmenu.cpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 77c022ffe..544bc028c 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -55,6 +55,7 @@
#include "gui/widgets/browserbox.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/progressbar.h"
+#include "gui/widgets/textfield.h"
#include "gui/widgets/whispertab.h"
#include "net/adminhandler.h"
@@ -93,11 +94,11 @@ PopupMenu::PopupMenu():
mDialog(nullptr),
mButton(nullptr),
mNick(""),
+ mTextField(nullptr),
mType(static_cast<int>(Being::UNKNOWN)),
mX(0),
mY(0)
{
- mBrowserBox->setPosition(4, 4);
mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND);
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
@@ -1534,6 +1535,16 @@ void PopupMenu::handleLink(const std::string &link,
if (outfitWindow)
outfitWindow->clearCurrentOutfit();
}
+ else if (link == "clipboard copy")
+ {
+ if (mTextField)
+ mTextField->handleCopy();
+ }
+ else if (link == "clipboard paste")
+ {
+ if (mTextField)
+ mTextField->handlePaste();
+ }
else if (!link.compare(0, 10, "guild-pos-"))
{
if (player_node)
@@ -1611,7 +1622,13 @@ void PopupMenu::handleLink(const std::string &link,
mItemId = 0;
mItemColor = 1;
mMapItem = nullptr;
+ mTab = nullptr;
+ mSpell = nullptr;
+ mWindow = nullptr;
+ mDialog = nullptr;
+ mButton = nullptr;
mNick.clear();
+ mTextField = nullptr;
mType = static_cast<int>(Being::UNKNOWN);
mX = 0;
mY = 0;
@@ -2040,12 +2057,33 @@ void PopupMenu::showUndressPopup(const int x, const int y,
mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
+}
+
+void PopupMenu::showTextFieldPopup(int x, int y, TextField *input)
+{
+ mX = x;
+ mY = y;
+ mTextField = input;
+
+ mBrowserBox->clearRows();
+ mBrowserBox->addRow("clipboard copy", _("Copy"));
+ mBrowserBox->addRow("clipboard paste", _("Paste"));
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow("cancel", _("Cancel"));
+
+ showPopup(x, y);
}
void PopupMenu::showPopup(int x, int y)
{
- setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8);
+ const int pad2 = 2 * getPadding();
+ const int bPad2 = 2 * mBrowserBox->getPadding();
+ mBrowserBox->setPosition(mPadding, mPadding);
+ // add padding to initial size before draw browserbox
+ mBrowserBox->setWidth(mBrowserBox->getWidth() + bPad2);
+ setContentSize(mBrowserBox->getWidth() + pad2,
+ mBrowserBox->getHeight() + pad2);
if (mainGraphics->mWidth < (x + getWidth() + 5))
x = mainGraphics->mWidth - getWidth();
if (mainGraphics->mHeight < (y + getHeight() + 5))
@@ -2211,6 +2249,13 @@ void PopupMenu::clear()
mDialog->close();
mDialog = nullptr;
}
+ mItem = nullptr;
+ mMapItem = nullptr;
+ mTab = nullptr;
+ mSpell = nullptr;
+ mWindow = nullptr;
+ mButton = nullptr;
+ mTextField = nullptr;
}
RenameListener::RenameListener() :