mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +00:00
LibWeb: Fire "mousedown" and "mousemove" events in the DOM :^)
This commit is contained in:
parent
f39e5352f0
commit
e265058768
3 changed files with 28 additions and 6 deletions
25
Base/home/anon/www/events.html
Normal file
25
Base/home/anon/www/events.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script>
|
||||||
|
function foo() {
|
||||||
|
alert("It loaded!");
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", foo);
|
||||||
|
|
||||||
|
function on_mousedown() {
|
||||||
|
alert("Mouse down!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_mousemove() {
|
||||||
|
alert("Mouse move!");
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("my_div").addEventListener("mousedown", on_mousedown);
|
||||||
|
document.getElementById("my_div").addEventListener("mousemove", on_mousemove);
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="my_div">Hello there!</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -17,18 +17,13 @@ h1 {
|
||||||
color: #a00;
|
color: #a00;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
function foo() {
|
|
||||||
alert("It loaded!");
|
|
||||||
}
|
|
||||||
document.addEventListener("DOMContentLoaded", foo);
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body link="#44f" vlink="#c4c" background="90s-bg.png">
|
<body link="#44f" vlink="#c4c" background="90s-bg.png">
|
||||||
<h1>Welcome to the Serenity Browser!</h1>
|
<h1>Welcome to the Serenity Browser!</h1>
|
||||||
<p>This is a very simple browser built on the LibWeb engine.</p>
|
<p>This is a very simple browser built on the LibWeb engine.</p>
|
||||||
<p>Some small test pages:</p>
|
<p>Some small test pages:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><a href="events.html">simple DOM events test</a></li>
|
||||||
<li><a href="dom.html">simple DOM JS test</a></li>
|
<li><a href="dom.html">simple DOM JS test</a></li>
|
||||||
<li><a href="alert.html">alert() test</a></li>
|
<li><a href="alert.html">alert() test</a></li>
|
||||||
<li><a href="small.html">small</a></li>
|
<li><a href="small.html">small</a></li>
|
||||||
|
|
|
@ -184,6 +184,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event)
|
||||||
#endif
|
#endif
|
||||||
is_hovering_link = true;
|
is_hovering_link = true;
|
||||||
}
|
}
|
||||||
|
const_cast<Node*>(node)->dispatch_event("mousemove");
|
||||||
}
|
}
|
||||||
if (m_in_mouse_selection) {
|
if (m_in_mouse_selection) {
|
||||||
layout_root()->selection().set_end({ result.layout_node, result.index_in_node });
|
layout_root()->selection().set_end({ result.layout_node, result.index_in_node });
|
||||||
|
@ -234,6 +235,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
|
||||||
m_in_mouse_selection = true;
|
m_in_mouse_selection = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const_cast<Node*>(node)->dispatch_event("mousedown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hovered_node_changed)
|
if (hovered_node_changed)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue