select Editbox character's offset
Posted: 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);
}
{
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);
}