diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-12-16 16:38:29 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-12-16 16:38:29 (GMT) |
| commit | 0c5e99aef6c997b8bce53189537523e7f742d64b (patch) | |
| tree | fbe46aa7b53660b6c399728f1adc1504b188dc98 /src/preview/PreviewView.cpp | |
| parent | 00190b4aabad65531ee0e859c3e4f358841238f6 (diff) | |
| parent | 06f8f88374a1b9e288da30d754ba4bf02768d863 (diff) | |
| download | powder-0c5e99aef6c997b8bce53189537523e7f742d64b.zip powder-0c5e99aef6c997b8bce53189537523e7f742d64b.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/The-Powder-Toy
Diffstat (limited to 'src/preview/PreviewView.cpp')
| -rw-r--r-- | src/preview/PreviewView.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/preview/PreviewView.cpp b/src/preview/PreviewView.cpp index d6c4448..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 { @@ -208,7 +208,6 @@ void PreviewView::commentBoxAutoHeight() int textWidth = Graphics::textwidth(addCommentBox->GetText().c_str()); if(textWidth+15 > Size.X-(XRES/2)-48) { - addCommentBox->SetMultiline(true); addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignTop; int oldSize = addCommentBox->Size.Y; @@ -225,7 +224,6 @@ void PreviewView::commentBoxAutoHeight() else { commentBoxHeight = 20; - addCommentBox->SetMultiline(false); addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; commentBoxPositionX = (XRES/2)+4; @@ -365,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(); @@ -431,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; @@ -467,6 +472,7 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender) addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment"); addCommentBox->SetActionCallback(new AutoCommentSizeAction(this)); addCommentBox->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; + addCommentBox->SetMultiline(true); AddComponent(addCommentBox); submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit"); submitCommentButton->SetActionCallback(new SubmitCommentAction(this)); |
