Dragging in a text field now selects the dragged-over text

Note: Seems to need optimization, may not work when text overruns field boundaries
This commit is contained in:
2014-12-22 16:32:44 -05:00
parent 6f04844c89
commit da975d6e3e

View File

@@ -114,6 +114,19 @@ bool cTextField::handleClick(location clickLoc) {
bool is_shift = sf::Keyboard::isKeyPressed(sf::Keyboard::LShift) || sf::Keyboard::isKeyPressed(sf::Keyboard::RShift);
set_ip(clickLoc, is_shift ? &cTextField::selectionPoint : &cTextField::insertionPoint);
if(!is_shift) selectionPoint = insertionPoint;
bool done = false;
sf::Event e;
while(!done) {
redraw();
if(!inWindow->pollEvent(e)) continue;
if(e.type == sf::Event::MouseButtonReleased){
done = true;
} else if(e.type == sf::Event::MouseMoved){
location newLoc(e.mouseMove.x, e.mouseMove.y);
set_ip(newLoc, &cTextField::selectionPoint);
}
}
redraw();
return true;
}