select Editbox character's offset

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

wang37921
Just popping in
Just popping in
Posts: 20
Joined: Thu Dec 24, 2009 11:22
Contact:

select Editbox character's offset

Postby wang37921 » Fri Sep 03, 2010 02:11

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

//MODIFY:does it should subtract namespace:TextArea's left edge here?
d_window->getLookNFeel();
const WidgetLookFeel& wlf = getLookNFeel();
const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*w));
wndx -= textArea.d_left;


//primary
//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);
}

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

Re: select Editbox character's offset

Postby CrazyEddie » Sun Sep 05, 2010 09:42

What's the nature of the issue here? You're saying that clicking in the editbox selects / moves the caret to the wrong place due to the offset of the TextArea? I'll test that out.

CE.

wang37921
Just popping in
Just popping in
Posts: 20
Joined: Thu Dec 24, 2009 11:22
Contact:

Re: select Editbox character's offset

Postby wang37921 » Mon Sep 06, 2010 03:02

maybe it's my propblem, when i change looknfeel, like below.It's let the image(set:BasicImage :imageEditBoxLeft) has some width.
the editbox like this: [beautyLeftEdge[TextArea]beautyRightEdge]

Code: Select all

    <NamedArea name="TextArea">
      <Area>
        <Dim type="LeftEdge" >
          <ImageDim imageset="BasicImage" image="EditBoxLeft" dimension="Width" />
        </Dim>
        <Dim type="TopEdge" >
          <AbsoluteDim value="5" />
        </Dim>
        <Dim type="RightEdge" >
          <UnifiedDim scale="1.0" offset="-5" type="RightEdge" />
        </Dim>
        <Dim type="BottomEdge" >
          <UnifiedDim scale="1.0" offset="-5" type="BottomEdge" />
        </Dim>
      </Area>
    </NamedArea>
    <ImagerySection name="container_normal">
      <FrameComponent>
        <Area>
          <Dim type="LeftEdge" >
            <AbsoluteDim value="0" />
          </Dim>
          <Dim type="TopEdge" >
            <AbsoluteDim value="0" />
          </Dim>
          <Dim type="Width" >
            <UnifiedDim scale="1" type="Width" />
          </Dim>
          <Dim type="Height" >
            <UnifiedDim scale="1" type="Height" />
          </Dim>
        </Area>
        <Image type="LeftEdge" imageset="BasicImage" image="EditBoxLeft" />
        <Image type="RightEdge" imageset="BasicImage" image="EditBoxRight" />
        <Image type="Background" imageset="BasicImage" image="EditBoxMiddle" />
      </FrameComponent>
    </ImagerySection>


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests