CEGUI的ComponentArea::getPixelRect()两个重载函数的参数,Editbox点击偏移错误


 d_window->getLookNFeel();
 const WidgetLookFeel& wlf = getLookNFeel();
 const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*w)); 

 const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*w), d_window->getOuterRectClipper());

///


        Rect getPixelRect(const Window& wnd, const Rect& container) const;
        Rect getPixelRect(const Window& wnd) const;

 

第一个函数得到的结果是该nameArea在该window的位置,以Rect参考的基准为基准

第二个函数得到的结果是nameArea在该window的位置,

一般用法就是注释上面的一段,改自FalEditbox,原来的减去的不知道是啥东东~反正改了looknfeel中的TextArea就会点不到真实的位置了,改了就好了。。。也算是输入文本的偏移错误吧。。。希望同问题的人可以搜索到,有点帮助~

 

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:还应该减去namespace:TextArea的左边缘
 d_window->getLookNFeel();
 const WidgetLookFeel& wlf = getLookNFeel();
 const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*w));
 wndx -= textArea.d_left;

 

//原来的
    //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);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值