summaryrefslogtreecommitdiff
path: root/src/preview/PreviewView.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-18 12:07:33 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-18 12:07:33 (GMT)
commita8e4221f38edefb5b342f470407b1f100d0248a3 (patch)
tree39f9d8036358c6150d5f7f6285a29e48a8c16882 /src/preview/PreviewView.cpp
parent78c4aba468a35166bf4ef5056b8e15be4098ba07 (diff)
downloadpowder-a8e4221f38edefb5b342f470407b1f100d0248a3.zip
powder-a8e4221f38edefb5b342f470407b1f100d0248a3.tar.gz
Working comment submission
Diffstat (limited to 'src/preview/PreviewView.cpp')
-rw-r--r--src/preview/PreviewView.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp
index d7c44b3..79d2cdd 100644
--- a/src/preview/PreviewView.cpp
+++ b/src/preview/PreviewView.cpp
@@ -28,6 +28,17 @@ public:
}
};
+class PreviewView::SubmitCommentAction: public ui::ButtonAction
+{
+ PreviewView * v;
+public:
+ SubmitCommentAction(PreviewView * v_){ v = v_; }
+ virtual void ActionCallback(ui::Button * sender)
+ {
+ v->submitComment();
+ }
+};
+
class PreviewView::AutoCommentSizeAction: public ui::TextboxAction
{
PreviewView * v;
@@ -361,6 +372,23 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
}
}
+void PreviewView::submitComment()
+{
+ if(addCommentBox)
+ {
+ std::string comment = std::string(addCommentBox->GetText());
+ submitCommentButton->Enabled = false;
+ addCommentBox->SetText("");
+ addCommentBox->SetPlaceholder("Submitting comment");
+ FocusComponent(NULL);
+
+ c->SubmitComment(comment);
+
+ addCommentBox->SetPlaceholder("Add comment");
+ submitCommentButton->Enabled = true;
+ }
+}
+
void PreviewView::displayComments(int yOffset)
{
for(int i = 0; i < commentComponents.size(); i++)
@@ -441,6 +469,7 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
addCommentBox->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(addCommentBox);
submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit");
+ submitCommentButton->SetActionCallback(new SubmitCommentAction(this));
//submitCommentButton->Enabled = false;
AddComponent(submitCommentButton);
}