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:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user