EditBox: get/setCursorPos

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

EditBox: get/setCursorPos

Post by Acki »

in order to this Thread I had a look at the GUIEditBox and thought that this functions could become handy... ;)

of course they will be added to the next IrrExtensions release, but as far as there are only a few additions I post it here now... :lol:

in "include\IGUIEditBox.h" add to the public part:

Code: Select all

//! Sets the position of the cursor.
//! \param pos New cursor position.
virtual void setCursorPos(int pos)=0;
//! Returns the curent position of the cursor.
virtual int getCursorPos()=0;
in "CGUIEditBox.h" add to the public part:

Code: Select all

virtual void setCursorPos(int pos);
virtual int getCursorPos();

and finaly in "CGUIEditBox.cpp" add:

Code: Select all

void CGUIEditBox::setCursorPos(int pos){
  CursorPos = pos;
  if(CursorPos < 0) CursorPos = 0;
  if((u32)CursorPos > Text.size()) CursorPos = Text.size();
  BlinkStartTime = os::Timer::getTime();
}
int CGUIEditBox::getCursorPos(){
  return CursorPos;
}
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply