make sure comment box height and cursor position don't go too far when it's resizing, fixes #82

This commit is contained in:
jacob1 2014-01-17 21:49:55 -05:00
parent 1f1062408c
commit 4e9a5bdaec
3 changed files with 9 additions and 1 deletions

View File

@ -122,6 +122,11 @@ void Textbox::OnContextMenuAction(int item)
} }
} }
void Textbox::resetCursorPosition()
{
Graphics::PositionAtCharIndex(multiline?((char*)textLines.c_str()):((char*)text.c_str()), cursor, cursorPositionX, cursorPositionY);
}
void Textbox::cutSelection() void Textbox::cutSelection()
{ {
char * clipboardText; char * clipboardText;

View File

@ -30,7 +30,7 @@ public:
virtual void SetPlaceholder(std::string text); virtual void SetPlaceholder(std::string text);
void SetBorder(bool border) { this->border = border; }; void SetBorder(bool border) { this->border = border; }
void SetHidden(bool hidden); void SetHidden(bool hidden);
bool GetHidden() { return masked; } bool GetHidden() { return masked; }
void SetActionCallback(TextboxAction * action) { actionCallback = action; } void SetActionCallback(TextboxAction * action) { actionCallback = action; }
@ -41,6 +41,7 @@ public:
ValidInput GetInputType(); ValidInput GetInputType();
void SetInputType(ValidInput input); void SetInputType(ValidInput input);
void resetCursorPosition();
//Determines if the given character is valid given the input type //Determines if the given character is valid given the input type
bool CharacterValid(Uint16 character); bool CharacterValid(Uint16 character);

View File

@ -351,6 +351,8 @@ void PreviewView::OnTick(float dt)
xdiff = 1*isign(sizeDiff.X); xdiff = 1*isign(sizeDiff.X);
addCommentBox->Size.X += xdiff; addCommentBox->Size.X += xdiff;
addCommentBox->Invalidate(); addCommentBox->Invalidate();
commentBoxAutoHeight(); //make sure textbox height is correct after resizes
addCommentBox->resetCursorPosition(); //make sure cursor is in correct position after resizes
} }
if(sizeDiff.Y!=0) if(sizeDiff.Y!=0)
{ {