Page 1 of 1

[solved] Editbox, mouse click carat ignores scrolled chars

Posted: Mon Dec 14, 2009 21:48
by enemymouse

Code: Select all

14/12/2009 01:32:53 (Std)    ---- Version 0.7.1 (Build: Oct 25 2009 Debug Microsoft Windows MSVC++ 9.0 32 bit) ----
14/12/2009 01:32:53 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
14/12/2009 01:32:53 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
14/12/2009 01:32:53 (Std)    ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
14/12/2009 01:32:53 (Std)    ---- Scripting module is: None ----


Try the following

1. put a Taharez or custom Editbox in your layout
2. type more than what would fit visually in the box, causing the text to scroll many chars to the left
3. click on any character
4. result - the text is scrolled back to the start and the carat is placed as if the text was not offset to the left at all.

This means of course that you'd never be able to click any portion of the string that falls outside range 0 to indexAtRightEdge

I did some digging in the Trunk and found:
src/WindowRendererSets/Falagard/FalEditbox.cpp, FalagardEditbox::getTextIndexFromPosition, line 355:

Code: Select all

        return w->getFont()->getCharAtPixel(w->getTextVisual(), wndx);


Shouldn't it be something like?

Code: Select all

        return w->getFont()->getCharAtPixel(w->getTextVisual(), wndx) + charsOutOfViewToLeftOfWindow;


Do I have that right?

Re: Editbox, mouse click carat ignores chars scrolled to left

Posted: Tue Dec 15, 2009 10:05
by CrazyEddie
Hi,

This is working fine for me. Not sure why it's not working for you.

Btw, the full code of that function is:

Code: Select all

size_t FalagardEditbox::getTextIndexFromPosition(const Point& pt) const
{
    Editbox* w = static_cast<Editbox*>(d_window);

    // calculate final window position to be checked
    float wndx = CoordConverter::screenToWindowX(*w, pt.d_x);

    wndx -= d_lastTextOffset;

    // Return the proper index
    if (w->isTextMasked())
        return w->getFont()->getCharAtPixel(
                String(w->getTextVisual().length(), w->getMaskCodePoint()),
                wndx);
    else
        return w->getFont()->getCharAtPixel(w->getTextVisual(), wndx);
}


The purpose of:

Code: Select all

    wndx -= d_lastTextOffset;

is to apply the appropriate offset.

I see you're probably using the prebuilt SDK, you might want to avoid that since we've confirmed that the release build config was messed up somewhat - not saying that's the source of this particular issue, but you may run into other issues down the road.

CE.

Re: Editbox, mouse click carat ignores chars scrolled to left

Posted: Tue Dec 15, 2009 18:55
by enemymouse
Thanks for clarifying that. I had the wrong idea about getTextVisual() as well as d_lastTextOffset.

Will try to build from source and see what happens.

[edit] -- It works properly with the new build, what a relief. Thanks Crazy Eddie!

Code: Select all

15/12/2009 14:44:20 (Std)    ---- Version 0.7.1 (Build: Dec 15 2009 Debug Microsoft Windows MSVC++ 9.0 32 bit) ----
15/12/2009 14:44:20 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
15/12/2009 14:44:20 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
15/12/2009 14:44:20 (Std)    ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
15/12/2009 14:44:20 (Std)    ---- Scripting module is: None ----

Re: [solved] Editbox, mouse click carat ignores scrolled chars

Posted: Wed Dec 16, 2009 09:54
by CrazyEddie
Cool. Glad you got it fixed :)

CE.