Hello,
As you can probubly guess from the thread title I am wondering if it is possible to set the position of the cursor in the editbox without editing the source and compiling it or extending the class (which I am now having a go at)?
I saw this thread (http://irrlicht.sourceforge.net/forum// ... 926#156926) and it was back in 2008 so I was wondering if anything has changed in this regard?
Many Thanks
DoctorZeus
Set Cursor Position on Editbox still not possible?
-
- Posts: 13
- Joined: Sun Jan 12, 2014 3:39 pm
-
- Posts: 13
- Joined: Sun Jan 12, 2014 3:39 pm
Re: Set Cursor Position on Editbox still not possible?
Also I saw via the thread that apparently this was possible via a project IrrExt which extended irrlicht.
However their last update was on 2013-04-02 and there are no files in the sourceforge folders so assuming it is dead or moved..?
However their last update was on 2013-04-02 and there are no files in the sourceforge folders so assuming it is dead or moved..?
Last edited by doctorzeus on Fri Jul 11, 2014 11:17 pm, edited 1 time in total.
Re: Set Cursor Position on Editbox still not possible?
Sorry, not possible. Corresponding feature-wish thread is here: http://sourceforge.net/p/irrlicht/feature-requests/116/
But depending on the situation you can work around and send keyboard-events to the editbox.
IrrEdit is a proprietary scene editor from the original Irrlicht programmer. Or maybe you mean something else.
But depending on the situation you can work around and send keyboard-events to the editbox.
IrrEdit is a proprietary scene editor from the original Irrlicht programmer. Or maybe you mean something else.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 13
- Joined: Sun Jan 12, 2014 3:39 pm
Re: Set Cursor Position on Editbox still not possible?
Ah right, well will be waiting for a bit by the looks of things then..CuteAlien wrote:Sorry, not possible. Corresponding feature-wish thread is here: http://sourceforge.net/p/irrlicht/feature-requests/116/
But depending on the situation you can work around and send keyboard-events to the editbox.
IrrEdit is a proprietary scene editor from the original Irrlicht programmer. Or maybe you mean something else.
Yes sorry (will edit if possible), I mean IrrExt..
Thanks
DoctorZeus
Last edited by doctorzeus on Sun Jul 13, 2014 9:23 am, edited 1 time in total.
-
- Posts: 13
- Joined: Sun Jan 12, 2014 3:39 pm
Re: Set Cursor Position on Editbox still not possible?
Ok well I sucessfully edited the code with this feature, although a fairly simple implementation there is a way of doing it on the thread, however here is a re-post for anyone looking at this later (all credit for this code to Acki from this http://irrlicht.sourceforge.net/forum// ... 926#156926 thread).
in "include\IGUIEditBox.h" add to the public part:
in "CGUIEditBox.h" add to the public part:
and finaly in "CGUIEditBox.cpp" add:
There are quite a few features that could be added to the editbox such as text alignment that could be added to the editbox, will be recomending that they be added to the next release.
DoctorZeus
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;
Code: Select all
virtual void setCursorPos(int pos);
virtual int getCursorPos();
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;
}
DoctorZeus
Re: Set Cursor Position on Editbox still not possible?
OK, just be aware that it's wrong when you have multi-line editboxes. I think it might work for single-line edit-boxes (no guarantee). To really understand I fear you have to read the source about how line-breaking is done inside the editbox (which is the part which needs a big rewrite - not just in the editbox and the reason why we have no getCursor/setCursor so far). But basically it's because text.length and cursorpos are not the same once newlines come into play.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm