mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibWeb: Update the cursor position when an editable element is clicked
With this change, clicking on an editable element, such as an `input` or `textarea` causes the cursor position to be updated to the current mouse position.
This commit is contained in:
parent
d4932196cc
commit
7f2582fca9
1 changed files with 4 additions and 2 deletions
|
@ -405,12 +405,14 @@ bool EventHandler::handle_mousedown(CSSPixelPoint position, CSSPixelPoint screen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we didn't focus anything, place the document text cursor at the mouse position.
|
|
||||||
// FIXME: This is all rather strange. Find a better solution.
|
|
||||||
if (!did_focus_something) {
|
if (!did_focus_something) {
|
||||||
if (auto* focused_element = document->focused_element())
|
if (auto* focused_element = document->focused_element())
|
||||||
HTML::run_unfocusing_steps(focused_element);
|
HTML::run_unfocusing_steps(focused_element);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we didn't focus anything, place the document text cursor at the mouse position.
|
||||||
|
// FIXME: This is all rather strange. Find a better solution.
|
||||||
|
if (!did_focus_something || paintable->dom_node()->is_editable()) {
|
||||||
auto& realm = document->realm();
|
auto& realm = document->realm();
|
||||||
m_browsing_context->set_cursor_position(DOM::Position::create(realm, *paintable->dom_node(), result->index_in_node));
|
m_browsing_context->set_cursor_position(DOM::Position::create(realm, *paintable->dom_node(), result->index_in_node));
|
||||||
if (auto selection = document->get_selection()) {
|
if (auto selection = document->get_selection()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue