[solved] Editbox, mouse click carat ignores scrolled chars

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

enemymouse
Just popping in
Just popping in
Posts: 5
Joined: Sun Dec 13, 2009 08:57

[solved] Editbox, mouse click carat ignores scrolled chars

Postby enemymouse » Mon Dec 14, 2009 21:48

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?
Last edited by enemymouse on Tue Dec 15, 2009 20:25, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

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

Postby CrazyEddie » Tue Dec 15, 2009 10:05

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.

enemymouse
Just popping in
Just popping in
Posts: 5
Joined: Sun Dec 13, 2009 08:57

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

Postby enemymouse » Tue Dec 15, 2009 18:55

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 ----

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

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

Postby CrazyEddie » Wed Dec 16, 2009 09:54

Cool. Glad you got it fixed :)

CE.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 7 guests