summaryrefslogtreecommitdiff
path: root/src/preview/PreviewView.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-12-16 03:55:53 (GMT)
committer jacob1 <jfu614@gmail.com>2012-12-16 03:55:53 (GMT)
commit462bd7bdf914b2663c7e574a0bf4de6d4a8a723c (patch)
treef1a4cc6e981400254a65ebd209179be5810cec86 /src/preview/PreviewView.cpp
parent1ef507d9e60348ed03f2edcd9c8d78d28d8d9d6f (diff)
downloadpowder-462bd7bdf914b2663c7e574a0bf4de6d4a8a723c.zip
powder-462bd7bdf914b2663c7e574a0bf4de6d4a8a723c.tar.gz
fix comments being deleted when hitting enter and opening a save or getting an error when commenting
Diffstat (limited to 'src/preview/PreviewView.cpp')
-rw-r--r--src/preview/PreviewView.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp
index 0e8c43c..fca7fa0 100644
--- a/src/preview/PreviewView.cpp
+++ b/src/preview/PreviewView.cpp
@@ -19,6 +19,7 @@
#include "search/Thumbnail.h"
#include "client/Client.h"
#include "interface/ScrollPanel.h"
+#include "interface/Keys.h"
class PreviewView::LoginAction: public ui::ButtonAction
{
@@ -121,7 +122,6 @@ PreviewView::PreviewView():
openButton->SetIcon(IconOpen);
openButton->SetActionCallback(new OpenAction(this));
AddComponent(openButton);
- SetOkayButton(openButton);
class BrowserOpenAction: public ui::ButtonAction
{
@@ -363,6 +363,12 @@ void PreviewView::OnMouseWheel(int x, int y, int d)
}
+void PreviewView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
+{
+ if ((key == KEY_ENTER || key == KEY_RETURN) && !addCommentBox->IsFocused())
+ openButton->DoAction();
+}
+
void PreviewView::NotifySaveChanged(PreviewModel * sender)
{
SaveInfo * save = sender->GetSave();
@@ -429,10 +435,11 @@ void PreviewView::submitComment()
std::string comment = std::string(addCommentBox->GetText());
submitCommentButton->Enabled = false;
addCommentBox->SetText("");
- addCommentBox->SetPlaceholder("Submitting comment");
+ addCommentBox->SetPlaceholder("Submitting comment"); //This doesn't appear to ever show since no separate thread is created
FocusComponent(NULL);
- c->SubmitComment(comment);
+ if (!c->SubmitComment(comment))
+ addCommentBox->SetText(comment);
addCommentBox->SetPlaceholder("Add comment");
submitCommentButton->Enabled = true;