CGUIEditBox maximum character limit

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Rush
Posts: 14
Joined: Wed Nov 24, 2004 11:00 am
Location: Hell

CGUIEditBox maximum character limit

Post by Rush »

There is a bug in CGUIEditbox that enables you to write more characters than the max limit you set. Simply, when you paste text from clipboard the max character limit isn't checked. Fix:
(CGUIEditBox.cpp, processKey() function)

Code: Select all

		case KEY_KEY_V:
			// paste from the clipboard
			if (Operator)
			{
				s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
				s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;

				// add new character
				c8* p = Operator->getTextFromClipboard();
				if (p)
				{
					if (MarkBegin == MarkEnd)
					{
						// insert text
						core::stringw s = Text.subString(0, CursorPos);
						s.append(p);
						s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
// here is the change
						if(s.size() <= Max)
						{
 	   					 Text = s;
						 s = p;
						 CursorPos += s.size();
                        } 
					}
					else
					{
						// replace text

						core::stringw s = Text.subString(0, realmbgn);
						s.append(p);
						s.append( Text.subString(realmend, Text.size()-realmend) );
//and here too
						if(s.size() <= Max)
						{
    						Text = s;
          					s = p;
		       				CursorPos = realmbgn + s.size();
                        } 
						
					}
				}

				MarkBegin = 0;
				MarkEnd = 0;
			}
			break;
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Ok, thanks for posting. Will be fixed in the next version.
Post Reply