lifecycle update
This commit is contained in:
parent
84ce42f106
commit
0b7a43efbd
14 changed files with 950 additions and 490 deletions
|
|
@ -362,6 +362,7 @@ function addSubmitListener(ptr, handlerID) {
|
||||||
|
|
||||||
const handler = function (event) {
|
const handler = function (event) {
|
||||||
const { ExecuteSubmitHandler } = window.crafter_webbuild_wasi.instance.exports;
|
const { ExecuteSubmitHandler } = window.crafter_webbuild_wasi.instance.exports;
|
||||||
|
event.preventDefault();
|
||||||
ExecuteSubmitHandler(handlerID);
|
ExecuteSubmitHandler(handlerID);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,180 @@
|
||||||
import Crafter.CppDOM;
|
import Crafter.CppDOM;
|
||||||
using namespace Crafter::CppDOM;
|
using namespace Crafter;
|
||||||
using namespace Crafter::CppDOMBindings;
|
|
||||||
import std;
|
import std;
|
||||||
|
|
||||||
|
HtmlElementPtr body("body", "<div id='container'>"
|
||||||
|
"<h1>Enhanced Event Handling Demo</h1>"
|
||||||
|
"<div id='events-container'>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Mouse Events</h2>"
|
||||||
|
"<button id='mouseButton'>Click Me!</button>"
|
||||||
|
"<div id='mouseOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Keyboard Events</h2>"
|
||||||
|
"<input type='text' id='keyInput' placeholder='Press keys here'>"
|
||||||
|
"<div id='keyOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Focus Events</h2>"
|
||||||
|
"<input type='text' id='focusInput' placeholder='Focus me!'>"
|
||||||
|
"<div id='focusOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Form Events</h2>"
|
||||||
|
"<form id='formElement'>"
|
||||||
|
"<input type='text' id='formInput' placeholder='Type something'>"
|
||||||
|
"<select id='formSelect'>"
|
||||||
|
"<option value='option1'>Option 1</option>"
|
||||||
|
"<option value='option2'>Option 2</option>"
|
||||||
|
"<option value='option3'>Option 3</option>"
|
||||||
|
"</select>"
|
||||||
|
"<button type='submit'>Submit Form</button>"
|
||||||
|
"</form>"
|
||||||
|
"<div id='formOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Window Events</h2>"
|
||||||
|
"<div id='windowOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Drag & Drop Events</h2>"
|
||||||
|
"<div id='dragSource' draggable='true'>Drag Me!</div>"
|
||||||
|
"<div id='dropTarget'>Drop Here</div>"
|
||||||
|
"<div id='dragOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"<div class='event-section'>"
|
||||||
|
"<h2>Wheel Events</h2>"
|
||||||
|
"<div id='wheelContainer'>Scroll here</div>"
|
||||||
|
"<div id='wheelOutput'></div>"
|
||||||
|
"</div>"
|
||||||
|
"</div>"
|
||||||
|
"</div>");
|
||||||
|
|
||||||
|
HtmlElementPtr mouseButton("mouseButton");
|
||||||
|
HtmlElementPtr mouseOutput("mouseOutput");
|
||||||
|
HtmlElementPtr keyInput("keyInput");
|
||||||
|
HtmlElementPtr keyOutput("keyOutput");
|
||||||
|
HtmlElementPtr focusInput("focusInput");
|
||||||
|
HtmlElementPtr focusOutput("focusOutput");
|
||||||
|
HtmlElementPtr formInput("formInput");
|
||||||
|
HtmlElementPtr formSelect("formSelect");
|
||||||
|
HtmlElementPtr formElement("formElement");
|
||||||
|
HtmlElementPtr formOutput("formOutput");
|
||||||
|
HtmlElementPtr windowOutput("windowOutput");
|
||||||
|
HtmlElementPtr dragSource("dragSource");
|
||||||
|
HtmlElementPtr dropTarget("dropTarget");
|
||||||
|
HtmlElementPtr dragOutput("dragOutput");
|
||||||
|
HtmlElementPtr wheelContainer("wheelContainer");
|
||||||
|
HtmlElementPtr wheelOutput("wheelOutput");
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
HtmlElementView body("body");
|
mouseButton.AddClickListener([&](MouseEvent event) {
|
||||||
body.SetInnerHTML("<h1>All Event Handling</h1>");
|
mouseOutput.SetInnerHTML(std::format("<p><strong>Click:</strong> X={}, Y={}</p>", event.clientX, event.clientY));
|
||||||
|
|
||||||
HtmlElementView div("div");
|
|
||||||
div.SetInnerHTML("<p>Click me!</p>");
|
|
||||||
div.SetStyle("padding: 20px; background-color: lightblue; cursor: pointer;");
|
|
||||||
|
|
||||||
// Add click handler
|
|
||||||
div.AddClickListener([](Crafter::MouseEvent e) {
|
|
||||||
std::cout << "Clicked!" << std::endl;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
body.AddChild(div);
|
mouseButton.AddMouseOverListener([&](MouseEvent event) {
|
||||||
|
mouseOutput.SetInnerHTML(std::format("<p><strong>Mouse Over:</strong> X={}, Y={}</p>", event.clientX, event.clientY));
|
||||||
|
});
|
||||||
|
|
||||||
// Demonstrate new bindings
|
mouseButton.AddMouseOutListener([&](MouseEvent event) {
|
||||||
std::string path = GetPathNameString();
|
mouseOutput.SetInnerHTML(std::format("<p><strong>Mouse Out:</strong> X={}, Y={}</p>", event.clientX, event.clientY));
|
||||||
std::cout << "Current path: " << path << std::endl;
|
});
|
||||||
|
|
||||||
return 0;
|
mouseButton.AddMouseMoveListener([&](MouseEvent event) {
|
||||||
|
mouseOutput.SetInnerHTML(std::format("<p><strong>Mouse Move:</strong> X={}, Y={}</p>", event.clientX, event.clientY));
|
||||||
|
});
|
||||||
|
|
||||||
|
mouseButton.AddMouseDownListener([&](MouseEvent event) {
|
||||||
|
mouseOutput.SetInnerHTML(std::format("<p><strong>Mouse Down:</strong> Button={}, X={}, Y={}</p>", event.button, event.clientX, event.clientY));
|
||||||
|
});
|
||||||
|
|
||||||
|
mouseButton.AddMouseUpListener([&](MouseEvent event) {
|
||||||
|
mouseOutput.SetInnerHTML(std::format("<p><strong>Mouse Up:</strong> Button={}, X={}, Y={}</p>", event.button, event.clientX, event.clientY));
|
||||||
|
});
|
||||||
|
|
||||||
|
keyInput.AddKeyDownListener([&](KeyboardEvent event) {
|
||||||
|
std::string keyInfo = std::format("<p><strong>Key Down:</strong> Key='{}', Code={}, Ctrl={}, Shift={}, Alt={}</p>",
|
||||||
|
event.key, event.keyCode, event.ctrlKey, event.shiftKey, event.altKey);
|
||||||
|
keyOutput.SetInnerHTML(keyInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
keyInput.AddKeyUpListener([&](KeyboardEvent event) {
|
||||||
|
std::string keyInfo = std::format("<p><strong>Key Up:</strong> Key='{}', Code={}, Ctrl={}, Shift={}, Alt={}</p>",
|
||||||
|
event.key, event.keyCode, event.ctrlKey, event.shiftKey, event.altKey);
|
||||||
|
keyOutput.SetInnerHTML(keyInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
keyInput.AddKeyPressListener([&](KeyboardEvent event) {
|
||||||
|
std::string keyInfo = std::format("<p><strong>Key Press:</strong> Key='{}', Code={}, Ctrl={}, Shift={}, Alt={}</p>",
|
||||||
|
event.key, event.keyCode, event.ctrlKey, event.shiftKey, event.altKey);
|
||||||
|
keyOutput.SetInnerHTML(keyInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Focus Events
|
||||||
|
focusInput.AddFocusListener([&](FocusEvent event) {
|
||||||
|
focusOutput.SetInnerHTML("<p><strong>Focus:</strong> Element gained focus</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
focusInput.AddBlurListener([&](FocusEvent event) {
|
||||||
|
focusOutput.SetInnerHTML("<p><strong>Blur:</strong> Element lost focus</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Form Events
|
||||||
|
formInput.AddInputListener([&](InputEvent event) {
|
||||||
|
formOutput.SetInnerHTML(std::format("<p><strong>Input:</strong> Value='{}'</p>", event.data));
|
||||||
|
});
|
||||||
|
|
||||||
|
formInput.AddChangeListener([&](ChangeEvent event) {
|
||||||
|
formOutput.SetInnerHTML(std::format("<p><strong>Change:</strong> Value='{}'</p>", event.value));
|
||||||
|
});
|
||||||
|
|
||||||
|
formSelect.AddChangeListener([&](ChangeEvent event) {
|
||||||
|
formOutput.SetInnerHTML(std::format("<p><strong>Select Change:</strong> Value='{}'</p>", event.value));
|
||||||
|
});
|
||||||
|
|
||||||
|
formElement.AddSubmitListener([&]() {
|
||||||
|
formOutput.SetInnerHTML("<p><strong>Submit:</strong> Form submitted successfully!</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
body.AddResizeListener([&](ResizeEvent event) {
|
||||||
|
windowOutput.SetInnerHTML(std::format("<p><strong>Resize:</strong> Width={}, Height={}</p>", event.width, event.height));
|
||||||
|
});
|
||||||
|
|
||||||
|
body.AddScrollListener([&](ScrollEvent event) {
|
||||||
|
windowOutput.SetInnerHTML(std::format("<p><strong>Scroll:</strong> X={}, Y={}</p>", event.scrollX, event.scrollY));
|
||||||
|
});
|
||||||
|
|
||||||
|
body.AddContextMenuListener([&](MouseEvent event) {
|
||||||
|
windowOutput.SetInnerHTML(std::format("<p><strong>Context Menu:</strong> X={}, Y={}</p>", event.clientX, event.clientY));
|
||||||
|
});
|
||||||
|
|
||||||
|
dragSource.AddDragStartListener([&](MouseEvent event) {
|
||||||
|
dragOutput.SetInnerHTML("<p><strong>Drag Start:</strong> Dragging started</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
dragSource.AddDragEndListener([&](MouseEvent event) {
|
||||||
|
dragOutput.SetInnerHTML("<p><strong>Drag End:</strong> Dragging ended</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
dropTarget.AddDragOverListener([&](MouseEvent event) {
|
||||||
|
dragOutput.SetInnerHTML("<p><strong>Drag Over:</strong> Dragging over drop target</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
dropTarget.AddDragEnterListener([&](MouseEvent event) {
|
||||||
|
dragOutput.SetInnerHTML("<p><strong>Drag Enter:</strong> Drag entered drop target</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
dropTarget.AddDragLeaveListener([&](MouseEvent event) {
|
||||||
|
dragOutput.SetInnerHTML("<p><strong>Drag Leave:</strong> Drag left drop target</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
dropTarget.AddDropListener([&](MouseEvent event) {
|
||||||
|
dragOutput.SetInnerHTML("<p><strong>Drop:</strong> Item dropped</p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
wheelContainer.AddWheelListener([&](WheelEvent event) {
|
||||||
|
wheelOutput.SetInnerHTML(std::format("<p><strong>Wheel:</strong> DeltaX={}, DeltaY={}, DeltaZ={}</p>",
|
||||||
|
event.deltaX, event.deltaY, event.deltaZ));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
import Crafter.CppDOM;
|
import Crafter.CppDOM;
|
||||||
import std;
|
import std;
|
||||||
|
using namespace Crafter;
|
||||||
using namespace Crafter::CppDOMBindings;
|
using namespace Crafter::CppDOMBindings;
|
||||||
|
|
||||||
int main(){
|
HtmlElementPtr body("body", "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
|
||||||
void* body = GetElementById("body");
|
|
||||||
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
|
|
||||||
|
|
||||||
Fetch("https://httpbin.org/get", [body](std::string result){
|
int main(){
|
||||||
|
Fetch("https://httpbin.org/get", [](std::string result){
|
||||||
if (!result.empty()) {
|
if (!result.empty()) {
|
||||||
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Response: " + result + "</p>");
|
body.SetInnerHTML("<h1>Fetch Example</h1><p>Response: " + result + "</p>");
|
||||||
} else {
|
} else {
|
||||||
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Failed to fetch data</p>");
|
body.SetInnerHTML("<h1>Fetch Example</h1><p>Failed to fetch data</p>");
|
||||||
}
|
}
|
||||||
FreeJs(body);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,7 @@ import Crafter.CppDOM;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
HtmlElementView body("body");
|
HtmlElementPtr body("body");
|
||||||
body.SetInnerHTML("Hello World!");
|
body.SetInnerHTML("Hello World!");
|
||||||
//No need to call FreeJs, this is done in the destructor of HtmlElementView.
|
//No need to call FreeJs, this is done in the destructor of HtmlElementPtr.
|
||||||
}
|
}
|
||||||
|
|
@ -2,16 +2,15 @@ import Crafter.CppDOM;
|
||||||
import std;
|
import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
HtmlElementPtr body("body", R"(<h1>Input GetValue() and SetValue() Example</h1><br><input id="input" type="text" placeholder="Enter your text here..."><br><button id="button">Change Value</button><p id ="valueOutput"></p>)");
|
||||||
HtmlElement* body = new HtmlElement("body", R"(<h1>Input GetValue() and SetValue() Example</h1><br><input id="input" type="text" placeholder="Enter your text here..."><br><button id="button">Change Value</button><p id ="valueOutput"></p>)");
|
HtmlElementPtr button("button");
|
||||||
HtmlElement* button = new HtmlElement("button");
|
HtmlElementPtr output("valueOutput");
|
||||||
HtmlElement* output = new HtmlElement("valueOutput");
|
HtmlElementPtr input("input");
|
||||||
HtmlElement* input = new HtmlElement("input");
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
button->AddClickListener([](Crafter::MouseEvent) {
|
button.AddClickListener([](Crafter::MouseEvent) {
|
||||||
std::string newValue = input->GetValue();
|
std::string newValue = input.GetValue();
|
||||||
output->SetInnerHTML(newValue);
|
output.SetInnerHTML(newValue);
|
||||||
input->SetValue("");
|
input.SetValue("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2,15 +2,15 @@ import Crafter.CppDOM;
|
||||||
import std;
|
import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
HtmlElementView body("body","<h1>Interactive Element Demo</h1>"
|
HtmlElementPtr body("body","<h1>Interactive Element Demo</h1>"
|
||||||
"<button id='myButton'>Click Me!</button>"
|
"<button id='myButton'>Click Me!</button>"
|
||||||
"<p id='output'>Click the button above</p>");
|
"<p id='output'>Click the button above</p>");
|
||||||
HtmlElementView* button = new HtmlElement("myButton"); //prevent destruction
|
HtmlElementPtr button("myButton");
|
||||||
|
HtmlElementPtr output("output");
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
button->AddClickListener([](Crafter::MouseEvent event){
|
button.AddClickListener([](Crafter::MouseEvent event){
|
||||||
auto output = HtmlElementView("output");
|
|
||||||
output.SetInnerHTML("Button was clicked at (" + std::to_string(event.clientX) + ", " + std::to_string(event.clientY) + ")!");
|
output.SetInnerHTML("Button was clicked at (" + std::to_string(event.clientX) + ", " + std::to_string(event.clientY) + ")!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
using namespace Crafter::CppDOMBindings;
|
using namespace Crafter::CppDOMBindings;
|
||||||
|
|
||||||
HtmlElementView* body = new HtmlElementView("body", R"(
|
HtmlElementPtr body("body", R"(
|
||||||
<nav>
|
<nav>
|
||||||
<h2 style="margin-bottom: 20px; padding: 10px; background-color: #f0f0f0;">SPA Navigation Demo</h2>
|
<h2 style="margin-bottom: 20px; padding: 10px; background-color: #f0f0f0;">SPA Navigation Demo</h2>
|
||||||
<a id="home" style="margin-right: 15px; text-decoration: none; color: blue; cursor: pointer;">Home</a>
|
<a id="home" style="margin-right: 15px; text-decoration: none; color: blue; cursor: pointer;">Home</a>
|
||||||
|
|
@ -12,36 +12,36 @@ HtmlElementView* body = new HtmlElementView("body", R"(
|
||||||
</nav>
|
</nav>
|
||||||
<div id="content" style="min-height: 200px; padding: 15px; border: 1px solid #ccc;"></div>
|
<div id="content" style="min-height: 200px; padding: 15px; border: 1px solid #ccc;"></div>
|
||||||
)");
|
)");
|
||||||
HtmlElementView* home = new HtmlElementView("home");
|
HtmlElementPtr home("home");
|
||||||
HtmlElementView* about = new HtmlElementView("about");
|
HtmlElementPtr about("about");
|
||||||
HtmlElementView* contact = new HtmlElementView("contact");
|
HtmlElementPtr contact("contact");
|
||||||
HtmlElementView* content = new HtmlElementView("content");
|
HtmlElementPtr content("content");
|
||||||
|
|
||||||
void UpdateContent(const std::string_view page) {
|
void UpdateContent(const std::string_view page) {
|
||||||
if (page == "home") {
|
if (page == "home") {
|
||||||
content->SetInnerHTML("<h3>Home Page</h3><p>Welcome to the Home page of our Single Page Application!</p><p>This demo shows how to use the new history.pushState and popstate event handling features.</p>");
|
content.SetInnerHTML("<h3>Home Page</h3><p>Welcome to the Home page of our Single Page Application!</p><p>This demo shows how to use the new history.pushState and popstate event handling features.</p>");
|
||||||
} else if (page == "about") {
|
} else if (page == "about") {
|
||||||
content->SetInnerHTML("<h3>About Page</h3><p>This is the About page.</p><p>Notice how the URL changes without reloading the page.</p>");
|
content.SetInnerHTML("<h3>About Page</h3><p>This is the About page.</p><p>Notice how the URL changes without reloading the page.</p>");
|
||||||
} else if (page == "contact") {
|
} else if (page == "contact") {
|
||||||
content->SetInnerHTML("<h3>Contact Page</h3><p>This is the Contact page.</p><p>You can navigate back and forth using the browser's back/forward buttons.</p>");
|
content.SetInnerHTML("<h3>Contact Page</h3><p>This is the Contact page.</p><p>You can navigate back and forth using the browser's back/forward buttons.</p>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
body->SetStyle("font-family: Arial, sans-serif; margin: 0; padding: 20px;");
|
body.SetStyle("font-family: Arial, sans-serif; margin: 0; padding: 20px;");
|
||||||
|
|
||||||
// Add click handlers for navigation
|
// Add click handlers for navigation
|
||||||
home->AddClickListener([](Crafter::MouseEvent e) {
|
home.AddClickListener([](Crafter::MouseEvent e) {
|
||||||
PushState("{\"page\": \"home\"}", "Home", "/");
|
PushState("{\"page\": \"home\"}", "Home", "/");
|
||||||
UpdateContent("home");
|
UpdateContent("home");
|
||||||
});
|
});
|
||||||
|
|
||||||
about->AddClickListener([](Crafter::MouseEvent e) {
|
about.AddClickListener([](Crafter::MouseEvent e) {
|
||||||
PushState("{\"page\": \"about\"}", "About", "/about");
|
PushState("{\"page\": \"about\"}", "About", "/about");
|
||||||
UpdateContent("about");
|
UpdateContent("about");
|
||||||
});
|
});
|
||||||
|
|
||||||
contact->AddClickListener([](Crafter::MouseEvent e) {
|
contact.AddClickListener([](Crafter::MouseEvent e) {
|
||||||
PushState("{\"page\": \"contact\"}", "Contact", "/contact");
|
PushState("{\"page\": \"contact\"}", "Contact", "/contact");
|
||||||
UpdateContent("contact");
|
UpdateContent("contact");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import Crafter.CppDOM;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
HtmlElementView body("body","<div id=\"myDiv\"></div>");
|
HtmlElementPtr body("body","<div id=\"myDiv\"></div>");
|
||||||
// Create a div element
|
// Create a div element
|
||||||
HtmlElementView div("myDiv");
|
HtmlElementPtr div("myDiv");
|
||||||
|
|
||||||
// Set some initial content
|
// Set some initial content
|
||||||
div.SetInnerHTML("<p>This is a styled paragraph</p>");
|
div.SetInnerHTML("<p>This is a styled paragraph</p>");
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,11 @@ struct Note {
|
||||||
|
|
||||||
void RenderNotes();
|
void RenderNotes();
|
||||||
|
|
||||||
// Global vector to store notes
|
std::vector<Note> notes;
|
||||||
std::vector<Note>* notes = new std::vector<Note>();
|
std::vector<HtmlElementView> noteButtons;
|
||||||
std::vector<HtmlElementView>* noteButtons = new std::vector<HtmlElementView>();
|
|
||||||
|
|
||||||
// Create the head section
|
// Create the head section
|
||||||
HtmlElementView* head = new HtmlElementView("head", R"(
|
HtmlElementPtr head("head", R"(
|
||||||
<title>Note Taking App</title>
|
<title>Note Taking App</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|
@ -123,7 +122,7 @@ HtmlElementView* head = new HtmlElementView("head", R"(
|
||||||
)");
|
)");
|
||||||
|
|
||||||
// Create the body section
|
// Create the body section
|
||||||
HtmlElementView* body = new HtmlElementView("body", R"(
|
HtmlElementPtr body("body", R"(
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<h1>📝 Note Taking App</h1>
|
<h1>📝 Note Taking App</h1>
|
||||||
|
|
||||||
|
|
@ -142,16 +141,16 @@ HtmlElementView* body = new HtmlElementView("body", R"(
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)");
|
)");
|
||||||
HtmlElementView* addNoteBtn = new HtmlElementView("addNoteBtn");
|
HtmlElementPtr addNoteBtn("addNoteBtn");
|
||||||
HtmlElementView* noteInput = new HtmlElementView("noteInput");
|
HtmlElementPtr noteInput("noteInput");
|
||||||
HtmlElementView* loadingIndicator = new HtmlElementView("loading");
|
HtmlElementPtr loadingIndicator("loading");
|
||||||
HtmlElementView* notesContainer = new HtmlElementView("notesContainer");
|
HtmlElementPtr notesContainer ("notesContainer");
|
||||||
|
|
||||||
void FetchNotes() {
|
void FetchNotes() {
|
||||||
loadingIndicator->SetInnerHTML("<p>Loading notes...</p>");
|
loadingIndicator.SetInnerHTML("<p>Loading notes...</p>");
|
||||||
|
|
||||||
Fetch("http://localhost:3000/getNotes", [](std::string input) {
|
Fetch("http://localhost:3000/getNotes", [](std::string input) {
|
||||||
notes->clear();
|
notes.clear();
|
||||||
std::istringstream stream(input);
|
std::istringstream stream(input);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
|
|
@ -169,35 +168,35 @@ void FetchNotes() {
|
||||||
content += line;
|
content += line;
|
||||||
}
|
}
|
||||||
|
|
||||||
notes->push_back(Note{id, content});
|
notes.push_back(Note{id, content});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadingIndicator->SetInnerHTML("<p>Notes loaded!</p>");
|
loadingIndicator.SetInnerHTML("<p>Notes loaded!</p>");
|
||||||
RenderNotes();
|
RenderNotes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to delete a note via the backend
|
// Function to delete a note via the backend
|
||||||
void DeleteNote(std::uint32_t id) {
|
void DeleteNote(std::uint32_t id) {
|
||||||
loadingIndicator->SetInnerHTML("<p>Deleting note...</p>");
|
loadingIndicator.SetInnerHTML("<p>Deleting note...</p>");
|
||||||
|
|
||||||
// Make POST request to delete note
|
// Make POST request to delete note
|
||||||
Fetch("http://localhost:3000/deleteNote", std::to_string(id), [](std::string content) {
|
Fetch("http://localhost:3000/deleteNote", std::to_string(id), [](std::string content) {
|
||||||
FetchNotes();
|
FetchNotes();
|
||||||
loadingIndicator->SetInnerHTML("<p>Note deleted!</p>");
|
loadingIndicator.SetInnerHTML("<p>Note deleted!</p>");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to render all notes to the DOM
|
// Function to render all notes to the DOM
|
||||||
void RenderNotes() {
|
void RenderNotes() {
|
||||||
if (notes->empty()) {
|
if (notes.empty()) {
|
||||||
notesContainer->SetInnerHTML("<p>No notes yet. Add one below!</p>");
|
notesContainer.SetInnerHTML("<p>No notes yet. Add one below!</p>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string html = "<div class='notes-list'>";
|
std::string html = "<div class='notes-list'>";
|
||||||
noteButtons->clear();
|
noteButtons.clear();
|
||||||
for (const Note& note : *notes) {
|
for (const Note& note : notes) {
|
||||||
html += std::format(
|
html += std::format(
|
||||||
R"(<div class='note-item' id='note-{}'>
|
R"(<div class='note-item' id='note-{}'>
|
||||||
<div class='note-content'>{}</div>
|
<div class='note-content'>{}</div>
|
||||||
|
|
@ -208,10 +207,10 @@ void RenderNotes() {
|
||||||
}
|
}
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
|
|
||||||
notesContainer->SetInnerHTML(html);
|
notesContainer.SetInnerHTML(html);
|
||||||
|
|
||||||
for (const Note& note : *notes) {
|
for (const Note& note : notes) {
|
||||||
HtmlElementView& view = noteButtons->emplace_back(std::format("note-{}-delete", note.id));
|
HtmlElementView& view = noteButtons.emplace_back(std::format("note-{}-delete", note.id));
|
||||||
view.AddClickListener([id = note.id](MouseEvent event) {
|
view.AddClickListener([id = note.id](MouseEvent event) {
|
||||||
DeleteNote(id);
|
DeleteNote(id);
|
||||||
});
|
});
|
||||||
|
|
@ -223,17 +222,17 @@ int main() {
|
||||||
FetchNotes();
|
FetchNotes();
|
||||||
|
|
||||||
// Add click listener to add note button
|
// Add click listener to add note button
|
||||||
addNoteBtn->AddClickListener([&](MouseEvent event) {
|
addNoteBtn.AddClickListener([&](MouseEvent event) {
|
||||||
std::string noteValue = noteInput->GetValue();
|
std::string noteValue = noteInput.GetValue();
|
||||||
std::cout << noteValue << std::endl;
|
std::cout << noteValue << std::endl;
|
||||||
if (!noteValue.empty()) {
|
if (!noteValue.empty()) {
|
||||||
loadingIndicator->SetInnerHTML("<p>Saving note...</p>");
|
loadingIndicator.SetInnerHTML("<p>Saving note...</p>");
|
||||||
Fetch("http://localhost:3000/createNote", noteValue, [noteValue](std::string content) {
|
Fetch("http://localhost:3000/createNote", noteValue, [noteValue](std::string content) {
|
||||||
std::cout << noteValue << std::endl;
|
std::cout << noteValue << std::endl;
|
||||||
notes->push_back({static_cast<std::uint32_t>(std::stoi(content)), noteValue});
|
notes.push_back({static_cast<std::uint32_t>(std::stoi(content)), noteValue});
|
||||||
noteInput->SetValue("");
|
noteInput.SetValue("");
|
||||||
RenderNotes();
|
RenderNotes();
|
||||||
loadingIndicator->SetInnerHTML("<p>Saved note!</p>");
|
loadingIndicator.SetInnerHTML("<p>Saved note!</p>");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
caddy file-server --listen :8080 --root bin/executable
|
caddy file-server --listen :8080 --root bin/executable
|
||||||
|
|
@ -26,47 +26,53 @@ import :BindingsImport;
|
||||||
import :EventTypes;
|
import :EventTypes;
|
||||||
|
|
||||||
namespace Crafter {
|
namespace Crafter {
|
||||||
HtmlElementView::HtmlElementView(const std::string_view id): ptr(CppDOMBindings::GetElementById(id)) {
|
HtmlElementPtr::HtmlElementPtr(const std::string_view id): ptr(CppDOMBindings::GetElementById(id)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlElementView::HtmlElementView(const std::string_view id, const std::string_view html): ptr(CppDOMBindings::GetElementById(id)) {
|
HtmlElementPtr::HtmlElementPtr(const std::string_view id, const std::string_view html): ptr(CppDOMBindings::GetElementById(id)) {
|
||||||
CppDOMBindings::SetInnerHTML(ptr, html);
|
CppDOMBindings::SetInnerHTML(ptr, html);
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlElementView::HtmlElementView(HtmlElementView&& other) : ptr(other.ptr), clickHandlers(std::move(other.clickHandlers)), mouseOverHandlers(std::move(other.mouseOverHandlers)), mouseOutHandlers(std::move(other.mouseOutHandlers)), mouseMoveHandlers(std::move(other.mouseMoveHandlers)), mouseDownHandlers(std::move(other.mouseDownHandlers)), mouseUpHandlers(std::move(other.mouseUpHandlers)), focusHandlers(std::move(other.focusHandlers)), blurHandlers(std::move(other.blurHandlers)), keyDownHandlers(std::move(other.keyDownHandlers)), keyUpHandlers(std::move(other.keyUpHandlers)), keyPressHandlers(std::move(other.keyPressHandlers)), changeHandlers(std::move(other.changeHandlers)), submitHandlers(std::move(other.submitHandlers)), inputHandlers(std::move(other.inputHandlers)), resizeHandlers(std::move(other.resizeHandlers)), scrollHandlers(std::move(other.scrollHandlers)), contextMenuHandlers(std::move(other.contextMenuHandlers)), dragStartHandlers(std::move(other.dragStartHandlers)), dragEndHandlers(std::move(other.dragEndHandlers)), dropHandlers(std::move(other.dropHandlers)), dragOverHandlers(std::move(other.dragOverHandlers)), dragEnterHandlers(std::move(other.dragEnterHandlers)), dragLeaveHandlers(std::move(other.dragLeaveHandlers)), wheelHandlers(std::move(other.wheelHandlers)) {
|
HtmlElementPtr::HtmlElementPtr(HtmlElementPtr&& other): ptr(other.ptr) {
|
||||||
other.ptr = nullptr;
|
other.ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::SetInnerHTML(const std::string_view html) {
|
HtmlElementPtr::~HtmlElementPtr() {
|
||||||
|
if(ptr != 0) {
|
||||||
|
CppDOMBindings::FreeJs(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::SetInnerHTML(const std::string_view html) {
|
||||||
CppDOMBindings::SetInnerHTML(ptr, html);
|
CppDOMBindings::SetInnerHTML(ptr, html);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::SetStyle(const std::string_view style) {
|
void HtmlElementPtr::SetStyle(const std::string_view style) {
|
||||||
CppDOMBindings::SetStyle(ptr, style);
|
CppDOMBindings::SetStyle(ptr, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::SetProperty(const std::string_view property, const std::string_view value) {
|
void HtmlElementPtr::SetProperty(const std::string_view property, const std::string_view value) {
|
||||||
CppDOMBindings::SetProperty(ptr, property, value);
|
CppDOMBindings::SetProperty(ptr, property, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::AddClass(const std::string_view className) {
|
void HtmlElementPtr::AddClass(const std::string_view className) {
|
||||||
CppDOMBindings::AddClass(ptr, className);
|
CppDOMBindings::AddClass(ptr, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveClass(const std::string_view className) {
|
void HtmlElementPtr::RemoveClass(const std::string_view className) {
|
||||||
CppDOMBindings::RemoveClass(ptr, className);
|
CppDOMBindings::RemoveClass(ptr, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::ToggleClass(const std::string_view className) {
|
void HtmlElementPtr::ToggleClass(const std::string_view className) {
|
||||||
CppDOMBindings::ToggleClass(ptr, className);
|
CppDOMBindings::ToggleClass(ptr, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HtmlElementView::HasClass(const std::string_view className) {
|
bool HtmlElementPtr::HasClass(const std::string_view className) {
|
||||||
return CppDOMBindings::HasClass(ptr, className);
|
return CppDOMBindings::HasClass(ptr, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HtmlElementView::GetValue() {
|
std::string HtmlElementPtr::GetValue() {
|
||||||
const char* value = CppDOMBindings::GetValue(ptr);
|
const char* value = CppDOMBindings::GetValue(ptr);
|
||||||
if(value != nullptr) {
|
if(value != nullptr) {
|
||||||
std::string result(value);
|
std::string result(value);
|
||||||
|
|
@ -77,446 +83,673 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::SetValue(const std::string_view value) {
|
void HtmlElementPtr::SetValue(const std::string_view value) {
|
||||||
CppDOMBindings::SetValue(ptr, value);
|
CppDOMBindings::SetValue(ptr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddClickListener(std::function<void(Crafter::MouseEvent)> callback) {
|
std::int32_t HtmlElementPtr::AddClickListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::clickHandlerMaxId++;
|
std::int32_t id = CppDOMBindings::clickHandlerMaxId++;
|
||||||
clickHandlers.push_back(id);
|
CppDOMBindings::clickHandlers.insert({id, callback});
|
||||||
CppDOMBindings::clickHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddClickListener(ptr, id);
|
CppDOMBindings::AddClickListener(ptr, id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveClickListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::clickHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveClickListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddMouseOverListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::mouseOverHandlerMaxId++;
|
||||||
|
CppDOMBindings::mouseOverHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddMouseOverListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveMouseOverListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::mouseOverHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveMouseOverListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddMouseOutListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::mouseOutHandlerMaxId++;
|
||||||
|
CppDOMBindings::mouseOutHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddMouseOutListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveMouseOutListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::mouseOutHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveMouseOutListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddMouseMoveListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::mouseMoveHandlerMaxId++;
|
||||||
|
CppDOMBindings::mouseMoveHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddMouseMoveListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveMouseMoveListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::mouseMoveHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveMouseMoveListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddMouseDownListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::mouseDownHandlerMaxId++;
|
||||||
|
CppDOMBindings::mouseDownHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddMouseDownListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveMouseDownListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::mouseDownHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveMouseDownListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddMouseUpListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::mouseUpHandlerMaxId++;
|
||||||
|
CppDOMBindings::mouseUpHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddMouseUpListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveMouseUpListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::mouseUpHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveMouseUpListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddFocusListener(std::function<void(Crafter::FocusEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::focusHandlerMaxId++;
|
||||||
|
CppDOMBindings::focusHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddFocusListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveFocusListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::focusHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveFocusListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddBlurListener(std::function<void(Crafter::FocusEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::blurHandlerMaxId++;
|
||||||
|
CppDOMBindings::blurHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddBlurListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveBlurListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::blurHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveBlurListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddKeyDownListener(std::function<void(KeyboardEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::keyDownHandlerMaxId++;
|
||||||
|
CppDOMBindings::keyDownHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddKeyDownListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveKeyDownListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::keyDownHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveKeyDownListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddKeyUpListener(std::function<void(KeyboardEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::keyUpHandlerMaxId++;
|
||||||
|
CppDOMBindings::keyUpHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddKeyUpListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveKeyUpListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::keyUpHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveKeyUpListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddKeyPressListener(std::function<void(KeyboardEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::keyPressHandlerMaxId++;
|
||||||
|
CppDOMBindings::keyPressHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddKeyPressListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveKeyPressListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::keyPressHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveKeyPressListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddChangeListener(std::function<void(ChangeEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::changeHandlerMaxId++;
|
||||||
|
CppDOMBindings::changeHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddChangeListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveChangeListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::changeHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveChangeListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddSubmitListener(std::function<void(void)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::submitHandlerMaxId++;
|
||||||
|
CppDOMBindings::submitHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddSubmitListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveSubmitListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::submitHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveSubmitListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddInputListener(std::function<void(InputEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::inputHandlerMaxId++;
|
||||||
|
CppDOMBindings::inputHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddInputListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveInputListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::inputHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveInputListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddResizeListener(std::function<void(ResizeEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::resizeHandlerMaxId++;
|
||||||
|
CppDOMBindings::resizeHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddResizeListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveResizeListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::resizeHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveResizeListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddScrollListener(std::function<void(ScrollEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::scrollHandlerMaxId++;
|
||||||
|
CppDOMBindings::scrollHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddScrollListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveScrollListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::scrollHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveScrollListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddContextMenuListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::contextMenuHandlerMaxId++;
|
||||||
|
CppDOMBindings::contextMenuHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddContextMenuListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveContextMenuListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::contextMenuHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveContextMenuListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddDragStartListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::dragStartHandlerMaxId++;
|
||||||
|
CppDOMBindings::dragStartHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddDragStartListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveDragStartListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::dragStartHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveDragStartListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddDragEndListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::dragEndHandlerMaxId++;
|
||||||
|
CppDOMBindings::dragEndHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddDragEndListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveDragEndListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::dragEndHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveDragEndListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddDropListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::dropHandlerMaxId++;
|
||||||
|
CppDOMBindings::dropHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddDropListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveDropListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::dropHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveDropListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddDragOverListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::dragOverHandlerMaxId++;
|
||||||
|
CppDOMBindings::dragOverHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddDragOverListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveDragOverListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::dragOverHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveDragOverListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddDragEnterListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::dragEnterHandlerMaxId++;
|
||||||
|
CppDOMBindings::dragEnterHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddDragEnterListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveDragEnterListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::dragEnterHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveDragEnterListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddDragLeaveListener(std::function<void(MouseEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::dragLeaveHandlerMaxId++;
|
||||||
|
CppDOMBindings::dragLeaveHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddDragLeaveListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveDragLeaveListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::dragLeaveHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveDragLeaveListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementPtr::AddWheelListener(std::function<void(WheelEvent)> callback) {
|
||||||
|
std::int32_t id = CppDOMBindings::wheelHandlerMaxId++;
|
||||||
|
CppDOMBindings::wheelHandlers.insert({id, callback});
|
||||||
|
CppDOMBindings::AddWheelListener(ptr, id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HtmlElementPtr::RemoveWheelListener(std::int32_t id) {
|
||||||
|
CppDOMBindings::wheelHandlers.erase(id);
|
||||||
|
CppDOMBindings::RemoveWheelListener(ptr, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
HtmlElementView::HtmlElementView(const std::string_view id): HtmlElementPtr(id) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HtmlElementView::HtmlElementView(const std::string_view id, const std::string_view html): HtmlElementPtr(id, html) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HtmlElementView::HtmlElementView(HtmlElementView&& other) : HtmlElementPtr(std::move(other)), clickHandlers(std::move(other.clickHandlers)), mouseOverHandlers(std::move(other.mouseOverHandlers)), mouseOutHandlers(std::move(other.mouseOutHandlers)), mouseMoveHandlers(std::move(other.mouseMoveHandlers)), mouseDownHandlers(std::move(other.mouseDownHandlers)), mouseUpHandlers(std::move(other.mouseUpHandlers)), focusHandlers(std::move(other.focusHandlers)), blurHandlers(std::move(other.blurHandlers)), keyDownHandlers(std::move(other.keyDownHandlers)), keyUpHandlers(std::move(other.keyUpHandlers)), keyPressHandlers(std::move(other.keyPressHandlers)), changeHandlers(std::move(other.changeHandlers)), submitHandlers(std::move(other.submitHandlers)), inputHandlers(std::move(other.inputHandlers)), resizeHandlers(std::move(other.resizeHandlers)), scrollHandlers(std::move(other.scrollHandlers)), contextMenuHandlers(std::move(other.contextMenuHandlers)), dragStartHandlers(std::move(other.dragStartHandlers)), dragEndHandlers(std::move(other.dragEndHandlers)), dropHandlers(std::move(other.dropHandlers)), dragOverHandlers(std::move(other.dragOverHandlers)), dragEnterHandlers(std::move(other.dragEnterHandlers)), dragLeaveHandlers(std::move(other.dragLeaveHandlers)), wheelHandlers(std::move(other.wheelHandlers)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HtmlElementView::~HtmlElementView() {
|
||||||
|
if(ptr != 0) {
|
||||||
|
for(std::int32_t handler : clickHandlers) {
|
||||||
|
CppDOMBindings::clickHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveClickListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : mouseOverHandlers) {
|
||||||
|
CppDOMBindings::mouseOverHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveMouseOverListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : mouseOutHandlers) {
|
||||||
|
CppDOMBindings::mouseOutHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveMouseOutListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : mouseMoveHandlers) {
|
||||||
|
CppDOMBindings::mouseMoveHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveMouseMoveListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : mouseDownHandlers) {
|
||||||
|
CppDOMBindings::mouseDownHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveMouseDownListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : mouseUpHandlers) {
|
||||||
|
CppDOMBindings::mouseUpHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveMouseUpListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : focusHandlers) {
|
||||||
|
CppDOMBindings::focusHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveFocusListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : blurHandlers) {
|
||||||
|
CppDOMBindings::blurHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveBlurListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : keyDownHandlers) {
|
||||||
|
CppDOMBindings::keyDownHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveKeyDownListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : keyUpHandlers) {
|
||||||
|
CppDOMBindings::keyUpHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveKeyUpListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : keyPressHandlers) {
|
||||||
|
CppDOMBindings::keyPressHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveKeyPressListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : changeHandlers) {
|
||||||
|
CppDOMBindings::changeHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveChangeListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : submitHandlers) {
|
||||||
|
CppDOMBindings::submitHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveSubmitListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : inputHandlers) {
|
||||||
|
CppDOMBindings::inputHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveInputListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : resizeHandlers) {
|
||||||
|
CppDOMBindings::resizeHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveResizeListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : scrollHandlers) {
|
||||||
|
CppDOMBindings::scrollHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveScrollListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : contextMenuHandlers) {
|
||||||
|
CppDOMBindings::contextMenuHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveContextMenuListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : dragStartHandlers) {
|
||||||
|
CppDOMBindings::dragStartHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveDragStartListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : dragEndHandlers) {
|
||||||
|
CppDOMBindings::dragEndHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveDragEndListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : dropHandlers) {
|
||||||
|
CppDOMBindings::dropHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveDropListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : dragOverHandlers) {
|
||||||
|
CppDOMBindings::dragOverHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveDragOverListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : dragEnterHandlers) {
|
||||||
|
CppDOMBindings::dragEnterHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveDragEnterListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : dragLeaveHandlers) {
|
||||||
|
CppDOMBindings::dragLeaveHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveDragLeaveListener(ptr, handler);
|
||||||
|
}
|
||||||
|
for(std::int32_t handler : wheelHandlers) {
|
||||||
|
CppDOMBindings::wheelHandlers.erase(handler);
|
||||||
|
CppDOMBindings::RemoveWheelListener(ptr, handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::int32_t HtmlElementView::AddClickListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
|
std::int32_t id = HtmlElementPtr::AddClickListener(callback);
|
||||||
|
clickHandlers.push_back(id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveClickListener(std::int32_t id) {
|
void HtmlElementView::RemoveClickListener(std::int32_t id) {
|
||||||
clickHandlers.erase(std::remove(clickHandlers.begin(), clickHandlers.end(), id), clickHandlers.end());
|
clickHandlers.erase(std::remove(clickHandlers.begin(), clickHandlers.end(), id), clickHandlers.end());
|
||||||
CppDOMBindings::clickHandlers->erase(id);
|
HtmlElementPtr::RemoveClickListener(id);
|
||||||
CppDOMBindings::RemoveClickListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddMouseOverListener(std::function<void(Crafter::MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddMouseOverListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::mouseOverHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddMouseOverListener(callback);
|
||||||
mouseOverHandlers.push_back(id);
|
mouseOverHandlers.push_back(id);
|
||||||
CppDOMBindings::mouseOverHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddMouseOverListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveMouseOverListener(std::int32_t id) {
|
void HtmlElementView::RemoveMouseOverListener(std::int32_t id) {
|
||||||
mouseOverHandlers.erase(std::remove(mouseOverHandlers.begin(), mouseOverHandlers.end(), id), mouseOverHandlers.end());
|
mouseOverHandlers.erase(std::remove(mouseOverHandlers.begin(), mouseOverHandlers.end(), id), mouseOverHandlers.end());
|
||||||
CppDOMBindings::mouseOverHandlers->erase(id);
|
HtmlElementPtr::RemoveMouseOverListener(id);
|
||||||
CppDOMBindings::RemoveMouseOverListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddMouseOutListener(std::function<void(Crafter::MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddMouseOutListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::mouseOutHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddMouseOutListener(callback);
|
||||||
mouseOutHandlers.push_back(id);
|
mouseOutHandlers.push_back(id);
|
||||||
CppDOMBindings::mouseOutHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddMouseOutListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveMouseOutListener(std::int32_t id) {
|
void HtmlElementView::RemoveMouseOutListener(std::int32_t id) {
|
||||||
mouseOutHandlers.erase(std::remove(mouseOutHandlers.begin(), mouseOutHandlers.end(), id), mouseOutHandlers.end());
|
mouseOutHandlers.erase(std::remove(mouseOutHandlers.begin(), mouseOutHandlers.end(), id), mouseOutHandlers.end());
|
||||||
CppDOMBindings::mouseOutHandlers->erase(id);
|
HtmlElementPtr::RemoveMouseOutListener(id);
|
||||||
CppDOMBindings::RemoveMouseOutListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddMouseMoveListener(std::function<void(Crafter::MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddMouseMoveListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::mouseMoveHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddMouseMoveListener(callback);
|
||||||
mouseMoveHandlers.push_back(id);
|
mouseMoveHandlers.push_back(id);
|
||||||
CppDOMBindings::mouseMoveHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddMouseMoveListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveMouseMoveListener(std::int32_t id) {
|
void HtmlElementView::RemoveMouseMoveListener(std::int32_t id) {
|
||||||
mouseMoveHandlers.erase(std::remove(mouseMoveHandlers.begin(), mouseMoveHandlers.end(), id), mouseMoveHandlers.end());
|
mouseMoveHandlers.erase(std::remove(mouseMoveHandlers.begin(), mouseMoveHandlers.end(), id), mouseMoveHandlers.end());
|
||||||
CppDOMBindings::mouseMoveHandlers->erase(id);
|
HtmlElementPtr::RemoveMouseMoveListener(id);
|
||||||
CppDOMBindings::RemoveMouseMoveListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddMouseDownListener(std::function<void(Crafter::MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddMouseDownListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::mouseDownHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddMouseDownListener(callback);
|
||||||
mouseDownHandlers.push_back(id);
|
mouseDownHandlers.push_back(id);
|
||||||
CppDOMBindings::mouseDownHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddMouseDownListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveMouseDownListener(std::int32_t id) {
|
void HtmlElementView::RemoveMouseDownListener(std::int32_t id) {
|
||||||
mouseDownHandlers.erase(std::remove(mouseDownHandlers.begin(), mouseDownHandlers.end(), id), mouseDownHandlers.end());
|
mouseDownHandlers.erase(std::remove(mouseDownHandlers.begin(), mouseDownHandlers.end(), id), mouseDownHandlers.end());
|
||||||
CppDOMBindings::mouseDownHandlers->erase(id);
|
HtmlElementPtr::RemoveMouseDownListener(id);
|
||||||
CppDOMBindings::RemoveMouseDownListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddMouseUpListener(std::function<void(Crafter::MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddMouseUpListener(std::function<void(Crafter::MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::mouseUpHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddMouseUpListener(callback);
|
||||||
mouseUpHandlers.push_back(id);
|
mouseUpHandlers.push_back(id);
|
||||||
CppDOMBindings::mouseUpHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddMouseUpListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveMouseUpListener(std::int32_t id) {
|
void HtmlElementView::RemoveMouseUpListener(std::int32_t id) {
|
||||||
mouseUpHandlers.erase(std::remove(mouseUpHandlers.begin(), mouseUpHandlers.end(), id), mouseUpHandlers.end());
|
mouseUpHandlers.erase(std::remove(mouseUpHandlers.begin(), mouseUpHandlers.end(), id), mouseUpHandlers.end());
|
||||||
CppDOMBindings::mouseUpHandlers->erase(id);
|
HtmlElementPtr::RemoveMouseUpListener(id);
|
||||||
CppDOMBindings::RemoveMouseUpListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddFocusListener(std::function<void(Crafter::FocusEvent)> callback) {
|
std::int32_t HtmlElementView::AddFocusListener(std::function<void(Crafter::FocusEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::focusHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddFocusListener(callback);
|
||||||
focusHandlers.push_back(id);
|
focusHandlers.push_back(id);
|
||||||
CppDOMBindings::focusHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddFocusListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveFocusListener(std::int32_t id) {
|
void HtmlElementView::RemoveFocusListener(std::int32_t id) {
|
||||||
focusHandlers.erase(std::remove(focusHandlers.begin(), focusHandlers.end(), id), focusHandlers.end());
|
focusHandlers.erase(std::remove(focusHandlers.begin(), focusHandlers.end(), id), focusHandlers.end());
|
||||||
CppDOMBindings::focusHandlers->erase(id);
|
HtmlElementPtr::RemoveFocusListener(id);
|
||||||
CppDOMBindings::RemoveFocusListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddBlurListener(std::function<void(Crafter::FocusEvent)> callback) {
|
std::int32_t HtmlElementView::AddBlurListener(std::function<void(Crafter::FocusEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::blurHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddBlurListener(callback);
|
||||||
blurHandlers.push_back(id);
|
blurHandlers.push_back(id);
|
||||||
CppDOMBindings::blurHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddBlurListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveBlurListener(std::int32_t id) {
|
void HtmlElementView::RemoveBlurListener(std::int32_t id) {
|
||||||
blurHandlers.erase(std::remove(blurHandlers.begin(), blurHandlers.end(), id), blurHandlers.end());
|
blurHandlers.erase(std::remove(blurHandlers.begin(), blurHandlers.end(), id), blurHandlers.end());
|
||||||
CppDOMBindings::blurHandlers->erase(id);
|
HtmlElementPtr::RemoveBlurListener(id);
|
||||||
CppDOMBindings::RemoveBlurListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddKeyDownListener(std::function<void(KeyboardEvent)> callback) {
|
std::int32_t HtmlElementView::AddKeyDownListener(std::function<void(KeyboardEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::keyDownHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddKeyDownListener(callback);
|
||||||
keyDownHandlers.push_back(id);
|
keyDownHandlers.push_back(id);
|
||||||
CppDOMBindings::keyDownHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddKeyDownListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveKeyDownListener(std::int32_t id) {
|
void HtmlElementView::RemoveKeyDownListener(std::int32_t id) {
|
||||||
keyDownHandlers.erase(std::remove(keyDownHandlers.begin(), keyDownHandlers.end(), id), keyDownHandlers.end());
|
keyDownHandlers.erase(std::remove(keyDownHandlers.begin(), keyDownHandlers.end(), id), keyDownHandlers.end());
|
||||||
CppDOMBindings::keyDownHandlers->erase(id);
|
HtmlElementPtr::RemoveKeyDownListener(id);
|
||||||
CppDOMBindings::RemoveKeyDownListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddKeyUpListener(std::function<void(KeyboardEvent)> callback) {
|
std::int32_t HtmlElementView::AddKeyUpListener(std::function<void(KeyboardEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::keyUpHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddKeyUpListener(callback);
|
||||||
keyUpHandlers.push_back(id);
|
keyUpHandlers.push_back(id);
|
||||||
CppDOMBindings::keyUpHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddKeyUpListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveKeyUpListener(std::int32_t id) {
|
void HtmlElementView::RemoveKeyUpListener(std::int32_t id) {
|
||||||
keyUpHandlers.erase(std::remove(keyUpHandlers.begin(), keyUpHandlers.end(), id), keyUpHandlers.end());
|
keyUpHandlers.erase(std::remove(keyUpHandlers.begin(), keyUpHandlers.end(), id), keyUpHandlers.end());
|
||||||
CppDOMBindings::keyUpHandlers->erase(id);
|
HtmlElementPtr::RemoveKeyUpListener(id);
|
||||||
CppDOMBindings::RemoveKeyUpListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddKeyPressListener(std::function<void(KeyboardEvent)> callback) {
|
std::int32_t HtmlElementView::AddKeyPressListener(std::function<void(KeyboardEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::keyPressHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddKeyPressListener(callback);
|
||||||
keyPressHandlers.push_back(id);
|
keyPressHandlers.push_back(id);
|
||||||
CppDOMBindings::keyPressHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddKeyPressListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveKeyPressListener(std::int32_t id) {
|
void HtmlElementView::RemoveKeyPressListener(std::int32_t id) {
|
||||||
keyPressHandlers.erase(std::remove(keyPressHandlers.begin(), keyPressHandlers.end(), id), keyPressHandlers.end());
|
keyPressHandlers.erase(std::remove(keyPressHandlers.begin(), keyPressHandlers.end(), id), keyPressHandlers.end());
|
||||||
CppDOMBindings::keyPressHandlers->erase(id);
|
HtmlElementPtr::RemoveKeyPressListener(id);
|
||||||
CppDOMBindings::RemoveKeyPressListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddChangeListener(std::function<void(ChangeEvent)> callback) {
|
std::int32_t HtmlElementView::AddChangeListener(std::function<void(ChangeEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::changeHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddChangeListener(callback);
|
||||||
changeHandlers.push_back(id);
|
changeHandlers.push_back(id);
|
||||||
CppDOMBindings::changeHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddChangeListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveChangeListener(std::int32_t id) {
|
void HtmlElementView::RemoveChangeListener(std::int32_t id) {
|
||||||
changeHandlers.erase(std::remove(changeHandlers.begin(), changeHandlers.end(), id), changeHandlers.end());
|
changeHandlers.erase(std::remove(changeHandlers.begin(), changeHandlers.end(), id), changeHandlers.end());
|
||||||
CppDOMBindings::changeHandlers->erase(id);
|
HtmlElementPtr::RemoveChangeListener(id);
|
||||||
CppDOMBindings::RemoveChangeListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddSubmitListener(std::function<void(void)> callback) {
|
std::int32_t HtmlElementView::AddSubmitListener(std::function<void(void)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::submitHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddSubmitListener(callback);
|
||||||
submitHandlers.push_back(id);
|
submitHandlers.push_back(id);
|
||||||
CppDOMBindings::submitHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddSubmitListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveSubmitListener(std::int32_t id) {
|
void HtmlElementView::RemoveSubmitListener(std::int32_t id) {
|
||||||
submitHandlers.erase(std::remove(submitHandlers.begin(), submitHandlers.end(), id), submitHandlers.end());
|
submitHandlers.erase(std::remove(submitHandlers.begin(), submitHandlers.end(), id), submitHandlers.end());
|
||||||
CppDOMBindings::submitHandlers->erase(id);
|
HtmlElementPtr::RemoveSubmitListener(id);
|
||||||
CppDOMBindings::RemoveSubmitListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddInputListener(std::function<void(InputEvent)> callback) {
|
std::int32_t HtmlElementView::AddInputListener(std::function<void(InputEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::inputHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddInputListener(callback);
|
||||||
inputHandlers.push_back(id);
|
inputHandlers.push_back(id);
|
||||||
CppDOMBindings::inputHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddInputListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveInputListener(std::int32_t id) {
|
void HtmlElementView::RemoveInputListener(std::int32_t id) {
|
||||||
inputHandlers.erase(std::remove(inputHandlers.begin(), inputHandlers.end(), id), inputHandlers.end());
|
inputHandlers.erase(std::remove(inputHandlers.begin(), inputHandlers.end(), id), inputHandlers.end());
|
||||||
CppDOMBindings::inputHandlers->erase(id);
|
HtmlElementPtr::RemoveInputListener(id);
|
||||||
CppDOMBindings::RemoveInputListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddResizeListener(std::function<void(ResizeEvent)> callback) {
|
std::int32_t HtmlElementView::AddResizeListener(std::function<void(ResizeEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::resizeHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddResizeListener(callback);
|
||||||
resizeHandlers.push_back(id);
|
resizeHandlers.push_back(id);
|
||||||
CppDOMBindings::resizeHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddResizeListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveResizeListener(std::int32_t id) {
|
void HtmlElementView::RemoveResizeListener(std::int32_t id) {
|
||||||
resizeHandlers.erase(std::remove(resizeHandlers.begin(), resizeHandlers.end(), id), resizeHandlers.end());
|
resizeHandlers.erase(std::remove(resizeHandlers.begin(), resizeHandlers.end(), id), resizeHandlers.end());
|
||||||
CppDOMBindings::resizeHandlers->erase(id);
|
HtmlElementPtr::RemoveResizeListener(id);
|
||||||
CppDOMBindings::RemoveResizeListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddScrollListener(std::function<void(ScrollEvent)> callback) {
|
std::int32_t HtmlElementView::AddScrollListener(std::function<void(ScrollEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::scrollHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddScrollListener(callback);
|
||||||
scrollHandlers.push_back(id);
|
scrollHandlers.push_back(id);
|
||||||
CppDOMBindings::scrollHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddScrollListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveScrollListener(std::int32_t id) {
|
void HtmlElementView::RemoveScrollListener(std::int32_t id) {
|
||||||
scrollHandlers.erase(std::remove(scrollHandlers.begin(), scrollHandlers.end(), id), scrollHandlers.end());
|
scrollHandlers.erase(std::remove(scrollHandlers.begin(), scrollHandlers.end(), id), scrollHandlers.end());
|
||||||
CppDOMBindings::scrollHandlers->erase(id);
|
HtmlElementPtr::RemoveScrollListener(id);
|
||||||
CppDOMBindings::RemoveScrollListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddContextMenuListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddContextMenuListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::contextMenuHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddContextMenuListener(callback);
|
||||||
contextMenuHandlers.push_back(id);
|
contextMenuHandlers.push_back(id);
|
||||||
CppDOMBindings::contextMenuHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddContextMenuListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveContextMenuListener(std::int32_t id) {
|
void HtmlElementView::RemoveContextMenuListener(std::int32_t id) {
|
||||||
contextMenuHandlers.erase(std::remove(contextMenuHandlers.begin(), contextMenuHandlers.end(), id), contextMenuHandlers.end());
|
contextMenuHandlers.erase(std::remove(contextMenuHandlers.begin(), contextMenuHandlers.end(), id), contextMenuHandlers.end());
|
||||||
CppDOMBindings::contextMenuHandlers->erase(id);
|
HtmlElementPtr::RemoveContextMenuListener(id);
|
||||||
CppDOMBindings::RemoveContextMenuListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddDragStartListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddDragStartListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::dragStartHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddDragStartListener(callback);
|
||||||
dragStartHandlers.push_back(id);
|
dragStartHandlers.push_back(id);
|
||||||
CppDOMBindings::dragStartHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddDragStartListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveDragStartListener(std::int32_t id) {
|
void HtmlElementView::RemoveDragStartListener(std::int32_t id) {
|
||||||
dragStartHandlers.erase(std::remove(dragStartHandlers.begin(), dragStartHandlers.end(), id), dragStartHandlers.end());
|
dragStartHandlers.erase(std::remove(dragStartHandlers.begin(), dragStartHandlers.end(), id), dragStartHandlers.end());
|
||||||
CppDOMBindings::dragStartHandlers->erase(id);
|
HtmlElementPtr::RemoveDragStartListener(id);
|
||||||
CppDOMBindings::RemoveDragStartListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddDragEndListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddDragEndListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::dragEndHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddDragEndListener(callback);
|
||||||
dragEndHandlers.push_back(id);
|
dragEndHandlers.push_back(id);
|
||||||
CppDOMBindings::dragEndHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddDragEndListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveDragEndListener(std::int32_t id) {
|
void HtmlElementView::RemoveDragEndListener(std::int32_t id) {
|
||||||
dragEndHandlers.erase(std::remove(dragEndHandlers.begin(), dragEndHandlers.end(), id), dragEndHandlers.end());
|
dragEndHandlers.erase(std::remove(dragEndHandlers.begin(), dragEndHandlers.end(), id), dragEndHandlers.end());
|
||||||
CppDOMBindings::dragEndHandlers->erase(id);
|
HtmlElementPtr::RemoveDragEndListener(id);
|
||||||
CppDOMBindings::RemoveDragEndListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddDropListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddDropListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::dropHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddDropListener(callback);
|
||||||
dropHandlers.push_back(id);
|
dropHandlers.push_back(id);
|
||||||
CppDOMBindings::dropHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddDropListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveDropListener(std::int32_t id) {
|
void HtmlElementView::RemoveDropListener(std::int32_t id) {
|
||||||
dropHandlers.erase(std::remove(dropHandlers.begin(), dropHandlers.end(), id), dropHandlers.end());
|
dropHandlers.erase(std::remove(dropHandlers.begin(), dropHandlers.end(), id), dropHandlers.end());
|
||||||
CppDOMBindings::dropHandlers->erase(id);
|
HtmlElementPtr::RemoveDropListener(id);
|
||||||
CppDOMBindings::RemoveDropListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddDragOverListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddDragOverListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::dragOverHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddDragOverListener(callback);
|
||||||
dragOverHandlers.push_back(id);
|
dragOverHandlers.push_back(id);
|
||||||
CppDOMBindings::dragOverHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddDragOverListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveDragOverListener(std::int32_t id) {
|
void HtmlElementView::RemoveDragOverListener(std::int32_t id) {
|
||||||
dragOverHandlers.erase(std::remove(dragOverHandlers.begin(), dragOverHandlers.end(), id), dragOverHandlers.end());
|
dragOverHandlers.erase(std::remove(dragOverHandlers.begin(), dragOverHandlers.end(), id), dragOverHandlers.end());
|
||||||
CppDOMBindings::dragOverHandlers->erase(id);
|
HtmlElementPtr::RemoveDragOverListener(id);
|
||||||
CppDOMBindings::RemoveDragOverListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddDragEnterListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddDragEnterListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::dragEnterHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddDragEnterListener(callback);
|
||||||
dragEnterHandlers.push_back(id);
|
dragEnterHandlers.push_back(id);
|
||||||
CppDOMBindings::dragEnterHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddDragEnterListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveDragEnterListener(std::int32_t id) {
|
void HtmlElementView::RemoveDragEnterListener(std::int32_t id) {
|
||||||
dragEnterHandlers.erase(std::remove(dragEnterHandlers.begin(), dragEnterHandlers.end(), id), dragEnterHandlers.end());
|
dragEnterHandlers.erase(std::remove(dragEnterHandlers.begin(), dragEnterHandlers.end(), id), dragEnterHandlers.end());
|
||||||
CppDOMBindings::dragEnterHandlers->erase(id);
|
HtmlElementPtr::RemoveDragEnterListener(id);
|
||||||
CppDOMBindings::RemoveDragEnterListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddDragLeaveListener(std::function<void(MouseEvent)> callback) {
|
std::int32_t HtmlElementView::AddDragLeaveListener(std::function<void(MouseEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::dragLeaveHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddDragLeaveListener(callback);
|
||||||
dragLeaveHandlers.push_back(id);
|
dragLeaveHandlers.push_back(id);
|
||||||
CppDOMBindings::dragLeaveHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddDragLeaveListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveDragLeaveListener(std::int32_t id) {
|
void HtmlElementView::RemoveDragLeaveListener(std::int32_t id) {
|
||||||
dragLeaveHandlers.erase(std::remove(dragLeaveHandlers.begin(), dragLeaveHandlers.end(), id), dragLeaveHandlers.end());
|
dragLeaveHandlers.erase(std::remove(dragLeaveHandlers.begin(), dragLeaveHandlers.end(), id), dragLeaveHandlers.end());
|
||||||
CppDOMBindings::dragLeaveHandlers->erase(id);
|
HtmlElementPtr::RemoveDragLeaveListener(id);
|
||||||
CppDOMBindings::RemoveDragLeaveListener(ptr, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::int32_t HtmlElementView::AddWheelListener(std::function<void(WheelEvent)> callback) {
|
std::int32_t HtmlElementView::AddWheelListener(std::function<void(WheelEvent)> callback) {
|
||||||
std::int32_t id = CppDOMBindings::wheelHandlerMaxId++;
|
std::int32_t id = HtmlElementPtr::AddWheelListener(callback);
|
||||||
wheelHandlers.push_back(id);
|
wheelHandlers.push_back(id);
|
||||||
CppDOMBindings::wheelHandlers->insert({id, callback});
|
|
||||||
CppDOMBindings::AddWheelListener(ptr, id);
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlElementView::RemoveWheelListener(std::int32_t id) {
|
void HtmlElementView::RemoveWheelListener(std::int32_t id) {
|
||||||
wheelHandlers.erase(std::remove(wheelHandlers.begin(), wheelHandlers.end(), id), wheelHandlers.end());
|
wheelHandlers.erase(std::remove(wheelHandlers.begin(), wheelHandlers.end(), id), wheelHandlers.end());
|
||||||
CppDOMBindings::wheelHandlers->erase(id);
|
HtmlElementPtr::RemoveWheelListener(id);
|
||||||
CppDOMBindings::RemoveWheelListener(ptr, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlElementView::~HtmlElementView() {
|
|
||||||
if(ptr != nullptr) {
|
|
||||||
for(std::int32_t handler : clickHandlers) {
|
|
||||||
CppDOMBindings::clickHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveClickListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : mouseOverHandlers) {
|
|
||||||
CppDOMBindings::mouseOverHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveMouseOverListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : mouseOutHandlers) {
|
|
||||||
CppDOMBindings::mouseOutHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveMouseOutListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : mouseMoveHandlers) {
|
|
||||||
CppDOMBindings::mouseMoveHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveMouseMoveListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : mouseDownHandlers) {
|
|
||||||
CppDOMBindings::mouseDownHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveMouseDownListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : mouseUpHandlers) {
|
|
||||||
CppDOMBindings::mouseUpHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveMouseUpListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : focusHandlers) {
|
|
||||||
CppDOMBindings::focusHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveFocusListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : blurHandlers) {
|
|
||||||
CppDOMBindings::blurHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveBlurListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : keyDownHandlers) {
|
|
||||||
CppDOMBindings::keyDownHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveKeyDownListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : keyUpHandlers) {
|
|
||||||
CppDOMBindings::keyUpHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveKeyUpListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : keyPressHandlers) {
|
|
||||||
CppDOMBindings::keyPressHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveKeyPressListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : changeHandlers) {
|
|
||||||
CppDOMBindings::changeHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveChangeListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : submitHandlers) {
|
|
||||||
CppDOMBindings::submitHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveSubmitListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : inputHandlers) {
|
|
||||||
CppDOMBindings::inputHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveInputListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : resizeHandlers) {
|
|
||||||
CppDOMBindings::resizeHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveResizeListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : scrollHandlers) {
|
|
||||||
CppDOMBindings::scrollHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveScrollListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : contextMenuHandlers) {
|
|
||||||
CppDOMBindings::contextMenuHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveContextMenuListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : dragStartHandlers) {
|
|
||||||
CppDOMBindings::dragStartHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveDragStartListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : dragEndHandlers) {
|
|
||||||
CppDOMBindings::dragEndHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveDragEndListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : dropHandlers) {
|
|
||||||
CppDOMBindings::dropHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveDropListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : dragOverHandlers) {
|
|
||||||
CppDOMBindings::dragOverHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveDragOverListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : dragEnterHandlers) {
|
|
||||||
CppDOMBindings::dragEnterHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveDragEnterListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : dragLeaveHandlers) {
|
|
||||||
CppDOMBindings::dragLeaveHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveDragLeaveListener(ptr, handler);
|
|
||||||
}
|
|
||||||
for(std::int32_t handler : wheelHandlers) {
|
|
||||||
CppDOMBindings::wheelHandlers->erase(handler);
|
|
||||||
CppDOMBindings::RemoveWheelListener(ptr, handler);
|
|
||||||
}
|
|
||||||
CppDOMBindings::FreeJs(ptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlElement::HtmlElement(const std::string_view id): HtmlElementView(id) {
|
HtmlElement::HtmlElement(const std::string_view id): HtmlElementView(id) {
|
||||||
|
|
@ -532,7 +765,7 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlElement::~HtmlElement() {
|
HtmlElement::~HtmlElement() {
|
||||||
if(ptr != nullptr) {
|
if(ptr != 0) {
|
||||||
CppDOMBindings::DeleteElement(ptr);
|
CppDOMBindings::DeleteElement(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,82 +5,82 @@ import :BindingsImport;
|
||||||
|
|
||||||
export namespace Crafter::CppDOMBindings {
|
export namespace Crafter::CppDOMBindings {
|
||||||
std::int32_t clickHandlerMaxId = 0;
|
std::int32_t clickHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* clickHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> clickHandlers;
|
||||||
|
|
||||||
std::int32_t mouseOverHandlerMaxId = 0;
|
std::int32_t mouseOverHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseOverHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseOverHandlers;
|
||||||
|
|
||||||
std::int32_t mouseOutHandlerMaxId = 0;
|
std::int32_t mouseOutHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseOutHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseOutHandlers;
|
||||||
|
|
||||||
std::int32_t mouseMoveHandlerMaxId = 0;
|
std::int32_t mouseMoveHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseMoveHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseMoveHandlers;
|
||||||
|
|
||||||
std::int32_t mouseDownHandlerMaxId = 0;
|
std::int32_t mouseDownHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseDownHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseDownHandlers;
|
||||||
|
|
||||||
std::int32_t mouseUpHandlerMaxId = 0;
|
std::int32_t mouseUpHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseUpHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseUpHandlers;
|
||||||
|
|
||||||
std::int32_t focusHandlerMaxId = 0;
|
std::int32_t focusHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>* focusHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>> focusHandlers;
|
||||||
|
|
||||||
std::int32_t blurHandlerMaxId = 0;
|
std::int32_t blurHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>* blurHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>> blurHandlers;
|
||||||
|
|
||||||
std::int32_t keyDownHandlerMaxId = 0;
|
std::int32_t keyDownHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>* keyDownHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>> keyDownHandlers;
|
||||||
|
|
||||||
std::int32_t keyUpHandlerMaxId = 0;
|
std::int32_t keyUpHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>* keyUpHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>> keyUpHandlers;
|
||||||
|
|
||||||
std::int32_t keyPressHandlerMaxId = 0;
|
std::int32_t keyPressHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>* keyPressHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>> keyPressHandlers;
|
||||||
|
|
||||||
std::int32_t changeHandlerMaxId = 0;
|
std::int32_t changeHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ChangeEvent)>>* changeHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::ChangeEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::ChangeEvent)>> changeHandlers;
|
||||||
|
|
||||||
std::int32_t submitHandlerMaxId = 0;
|
std::int32_t submitHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(void)>>* submitHandlers = new std::unordered_map<std::int32_t, std::function<void(void)>>();
|
std::unordered_map<std::int32_t, std::function<void(void)>> submitHandlers;
|
||||||
|
|
||||||
std::int32_t inputHandlerMaxId = 0;
|
std::int32_t inputHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::InputEvent)>>* inputHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::InputEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::InputEvent)>> inputHandlers;
|
||||||
|
|
||||||
std::int32_t resizeHandlerMaxId = 0;
|
std::int32_t resizeHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ResizeEvent)>>* resizeHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::ResizeEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::ResizeEvent)>> resizeHandlers;
|
||||||
|
|
||||||
std::int32_t scrollHandlerMaxId = 0;
|
std::int32_t scrollHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ScrollEvent)>>* scrollHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::ScrollEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::ScrollEvent)>> scrollHandlers;
|
||||||
|
|
||||||
std::int32_t contextMenuHandlerMaxId = 0;
|
std::int32_t contextMenuHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* contextMenuHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> contextMenuHandlers;
|
||||||
|
|
||||||
std::int32_t dragStartHandlerMaxId = 0;
|
std::int32_t dragStartHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragStartHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragStartHandlers;
|
||||||
|
|
||||||
std::int32_t dragEndHandlerMaxId = 0;
|
std::int32_t dragEndHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragEndHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragEndHandlers;
|
||||||
|
|
||||||
std::int32_t dropHandlerMaxId = 0;
|
std::int32_t dropHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dropHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dropHandlers;
|
||||||
|
|
||||||
std::int32_t wheelHandlerMaxId = 0;
|
std::int32_t wheelHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::WheelEvent)>>* wheelHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::WheelEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::WheelEvent)>> wheelHandlers;
|
||||||
|
|
||||||
std::int32_t dragOverHandlerMaxId = 0;
|
std::int32_t dragOverHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragOverHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragOverHandlers;
|
||||||
|
|
||||||
std::int32_t dragEnterHandlerMaxId = 0;
|
std::int32_t dragEnterHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragEnterHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragEnterHandlers;
|
||||||
|
|
||||||
std::int32_t dragLeaveHandlerMaxId = 0;
|
std::int32_t dragLeaveHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragLeaveHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragLeaveHandlers;
|
||||||
|
|
||||||
std::int32_t popStateHandlerMaxId = 0;
|
std::int32_t popStateHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(void)>>* popStateHandlers = new std::unordered_map<std::int32_t, std::function<void(void)>>();
|
std::unordered_map<std::int32_t, std::function<void(void)>> popStateHandlers;
|
||||||
|
|
||||||
std::int32_t fetchHandlerMaxId = 0;
|
std::int32_t fetchHandlerMaxId = 0;
|
||||||
std::unordered_map<std::int32_t, std::function<void(std::string)>>* fetchHandlers = new std::unordered_map<std::int32_t, std::function<void(std::string)>>();
|
std::unordered_map<std::int32_t, std::function<void(std::string)>> fetchHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -92,114 +92,110 @@ extern "C" {
|
||||||
std::free(ptr);
|
std::free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("deleteElement"))) void DeleteElement(void* ptr) {
|
|
||||||
// This will be implemented in JavaScript
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteClickHandler"))) void ExecuteClickHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteClickHandler"))) void ExecuteClickHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::clickHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::clickHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteMouseOverHandler"))) void ExecuteMouseOverHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteMouseOverHandler"))) void ExecuteMouseOverHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::mouseOverHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::mouseOverHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteMouseOutHandler"))) void ExecuteMouseOutHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteMouseOutHandler"))) void ExecuteMouseOutHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::mouseOutHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::mouseOutHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteMouseMoveHandler"))) void ExecuteMouseMoveHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteMouseMoveHandler"))) void ExecuteMouseMoveHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::mouseMoveHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::mouseMoveHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteMouseDownHandler"))) void ExecuteMouseDownHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button,std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteMouseDownHandler"))) void ExecuteMouseDownHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button,std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::mouseDownHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::mouseDownHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteMouseUpHandler"))) void ExecuteMouseUpHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteMouseUpHandler"))) void ExecuteMouseUpHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::mouseUpHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::mouseUpHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteFocusHandler"))) void ExecuteFocusHandler(std::int32_t handlerID, void* target, void* relatedTarget) {
|
__attribute__((export_name("ExecuteFocusHandler"))) void ExecuteFocusHandler(std::int32_t handlerID, void* target, void* relatedTarget) {
|
||||||
Crafter::CppDOMBindings::focusHandlers->find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
Crafter::CppDOMBindings::focusHandlers.find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteBlurHandler"))) void ExecuteBlurHandler(std::int32_t handlerID, void* target, void* relatedTarget) {
|
__attribute__((export_name("ExecuteBlurHandler"))) void ExecuteBlurHandler(std::int32_t handlerID, void* target, void* relatedTarget) {
|
||||||
Crafter::CppDOMBindings::blurHandlers->find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
Crafter::CppDOMBindings::blurHandlers.find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteKeyDownHandler"))) void ExecuteKeyDownHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteKeyDownHandler"))) void ExecuteKeyDownHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::keyDownHandlers->find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::keyDownHandlers.find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteKeyUpHandler"))) void ExecuteKeyUpHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteKeyUpHandler"))) void ExecuteKeyUpHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::keyUpHandlers->find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::keyUpHandlers.find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteKeyPressHandler"))) void ExecuteKeyPressHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteKeyPressHandler"))) void ExecuteKeyPressHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::keyPressHandlers->find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::keyPressHandlers.find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteChangeHandler"))) void ExecuteChangeHandler(std::int32_t handlerID, const char* value) {
|
__attribute__((export_name("ExecuteChangeHandler"))) void ExecuteChangeHandler(std::int32_t handlerID, const char* value) {
|
||||||
Crafter::CppDOMBindings::changeHandlers->find(handlerID)->second(Crafter::ChangeEvent(value));
|
Crafter::CppDOMBindings::changeHandlers.find(handlerID)->second(Crafter::ChangeEvent(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteSubmitHandler"))) void ExecuteSubmitHandler(std::int32_t handlerID) {
|
__attribute__((export_name("ExecuteSubmitHandler"))) void ExecuteSubmitHandler(std::int32_t handlerID) {
|
||||||
Crafter::CppDOMBindings::submitHandlers->find(handlerID)->second();
|
Crafter::CppDOMBindings::submitHandlers.find(handlerID)->second();
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteInputHandler"))) void ExecuteInputHandler(std::int32_t handlerID, const char* data, bool isComposing) {
|
__attribute__((export_name("ExecuteInputHandler"))) void ExecuteInputHandler(std::int32_t handlerID, const char* data, bool isComposing) {
|
||||||
Crafter::CppDOMBindings::inputHandlers->find(handlerID)->second(Crafter::InputEvent(data, isComposing));
|
Crafter::CppDOMBindings::inputHandlers.find(handlerID)->second(Crafter::InputEvent(data, isComposing));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteResizeHandler"))) void ExecuteResizeHandler(std::int32_t handlerID, std::int32_t width, std::int32_t height) {
|
__attribute__((export_name("ExecuteResizeHandler"))) void ExecuteResizeHandler(std::int32_t handlerID, std::int32_t width, std::int32_t height) {
|
||||||
Crafter::CppDOMBindings::resizeHandlers->find(handlerID)->second(Crafter::ResizeEvent(width, height));
|
Crafter::CppDOMBindings::resizeHandlers.find(handlerID)->second(Crafter::ResizeEvent(width, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteScrollHandler"))) void ExecuteScrollHandler(std::int32_t handlerID, double scrollX, double scrollY) {
|
__attribute__((export_name("ExecuteScrollHandler"))) void ExecuteScrollHandler(std::int32_t handlerID, double scrollX, double scrollY) {
|
||||||
Crafter::CppDOMBindings::scrollHandlers->find(handlerID)->second(Crafter::ScrollEvent(scrollX, scrollY));
|
Crafter::CppDOMBindings::scrollHandlers.find(handlerID)->second(Crafter::ScrollEvent(scrollX, scrollY));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteContextMenuHandler"))) void ExecuteContextMenuHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteContextMenuHandler"))) void ExecuteContextMenuHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::contextMenuHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::contextMenuHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteDragStartHandler"))) void ExecuteDragStartHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteDragStartHandler"))) void ExecuteDragStartHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::dragStartHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::dragStartHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteDragEndHandler"))) void ExecuteDragEndHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteDragEndHandler"))) void ExecuteDragEndHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::dragEndHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::dragEndHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteDropHandler"))) void ExecuteDropHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteDropHandler"))) void ExecuteDropHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::dropHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::dropHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteWheelHandler"))) void ExecuteWheelHandler(std::int32_t handlerID, double deltaX, double deltaY, double deltaZ, std::int32_t deltaMode, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteWheelHandler"))) void ExecuteWheelHandler(std::int32_t handlerID, double deltaX, double deltaY, double deltaZ, std::int32_t deltaMode, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::wheelHandlers->find(handlerID)->second(Crafter::WheelEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey, deltaX, deltaY, deltaZ));
|
Crafter::CppDOMBindings::wheelHandlers.find(handlerID)->second(Crafter::WheelEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey, deltaX, deltaY, deltaZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteDragOverHandler"))) void ExecuteDragOverHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteDragOverHandler"))) void ExecuteDragOverHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::dragOverHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::dragOverHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteDragEnterHandler"))) void ExecuteDragEnterHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteDragEnterHandler"))) void ExecuteDragEnterHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::dragEnterHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::dragEnterHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteDragLeaveHandler"))) void ExecuteDragLeaveHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
__attribute__((export_name("ExecuteDragLeaveHandler"))) void ExecuteDragLeaveHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||||
Crafter::CppDOMBindings::dragLeaveHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
Crafter::CppDOMBindings::dragLeaveHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecuteFetchHandler"))) void ExecuteFetchHandler(std::int32_t handlerID, const char* response) {
|
__attribute__((export_name("ExecuteFetchHandler"))) void ExecuteFetchHandler(std::int32_t handlerID, const char* response) {
|
||||||
std::cout << handlerID << std::endl;
|
std::cout << handlerID << std::endl;
|
||||||
Crafter::CppDOMBindings::fetchHandlers->find(handlerID)->second(response);
|
Crafter::CppDOMBindings::fetchHandlers.find(handlerID)->second(response);
|
||||||
Crafter::CppDOMBindings::fetchHandlers->erase(handlerID);
|
Crafter::CppDOMBindings::fetchHandlers.erase(handlerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((export_name("ExecutePopStateHandler"))) void ExecutePopStateHandler(std::int32_t handlerID) {
|
__attribute__((export_name("ExecutePopStateHandler"))) void ExecutePopStateHandler(std::int32_t handlerID) {
|
||||||
Crafter::CppDOMBindings::popStateHandlers->find(handlerID)->second();
|
Crafter::CppDOMBindings::popStateHandlers.find(handlerID)->second();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,12 +204,12 @@ export namespace Crafter::CppDOMBindings {
|
||||||
__attribute__((import_module("env"), import_name("fetchWithBody"))) void FetchWithBody(const char* url, std::int32_t urlLenght, const char* body, std::int32_t bodyLength, std::int32_t handlerID);
|
__attribute__((import_module("env"), import_name("fetchWithBody"))) void FetchWithBody(const char* url, std::int32_t urlLenght, const char* body, std::int32_t bodyLength, std::int32_t handlerID);
|
||||||
void Fetch(const std::string_view url, std::function<void(std::string)> callback) {
|
void Fetch(const std::string_view url, std::function<void(std::string)> callback) {
|
||||||
std::int32_t id = fetchHandlerMaxId++;
|
std::int32_t id = fetchHandlerMaxId++;
|
||||||
CppDOMBindings::fetchHandlers->insert({id, callback});
|
CppDOMBindings::fetchHandlers.insert({id, callback});
|
||||||
Fetch(url.data(), url.size(), id);
|
Fetch(url.data(), url.size(), id);
|
||||||
}
|
}
|
||||||
void Fetch(const std::string_view url, const std::string_view body, std::function<void(std::string)> callback) {
|
void Fetch(const std::string_view url, const std::string_view body, std::function<void(std::string)> callback) {
|
||||||
std::int32_t id = fetchHandlerMaxId++;
|
std::int32_t id = fetchHandlerMaxId++;
|
||||||
CppDOMBindings::fetchHandlers->insert({id, callback});
|
CppDOMBindings::fetchHandlers.insert({id, callback});
|
||||||
FetchWithBody(url.data(), url.size(), body.data(), body.size(), id);
|
FetchWithBody(url.data(), url.size(), body.data(), body.size(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,14 +221,14 @@ export namespace Crafter::CppDOMBindings {
|
||||||
|
|
||||||
std::int32_t AddPopStateListener(std::function<void(void)> callback) {
|
std::int32_t AddPopStateListener(std::function<void(void)> callback) {
|
||||||
std::int32_t id = popStateHandlerMaxId++;
|
std::int32_t id = popStateHandlerMaxId++;
|
||||||
popStateHandlers->insert({id, callback});
|
popStateHandlers.insert({id, callback});
|
||||||
AddPopStateListener(id);
|
AddPopStateListener(id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemovePopStateListener(std::int32_t id) {
|
void RemovePopStateListener(std::int32_t id) {
|
||||||
RemovePopStateListener(id);
|
RemovePopStateListener(id);
|
||||||
popStateHandlers->erase(id);
|
popStateHandlers.erase(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushState(const std::string_view data, const std::string_view title, const std::string_view url) {
|
void PushState(const std::string_view data, const std::string_view title, const std::string_view url) {
|
||||||
|
|
|
||||||
|
|
@ -23,131 +23,131 @@ import std;
|
||||||
import :EventTypes;
|
import :EventTypes;
|
||||||
|
|
||||||
export namespace Crafter::CppDOMBindings {
|
export namespace Crafter::CppDOMBindings {
|
||||||
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr);
|
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(std::int32_t ptr);
|
||||||
__attribute__((import_module("env"), import_name("getElementById"))) void* GetElementById(const char* id, std::int32_t idLenght);
|
__attribute__((import_module("env"), import_name("getElementById"))) std::int32_t GetElementById(const char* id, std::int32_t idLenght);
|
||||||
void* GetElementById(const std::string_view id) {
|
std::int32_t GetElementById(const std::string_view id) {
|
||||||
return GetElementById(id.data(), id.size());
|
return GetElementById(id.data(), id.size());
|
||||||
}
|
}
|
||||||
__attribute__((import_module("env"), import_name("setInnerHTML"))) void SetInnerHTML(void* ptr, const char* html, std::int32_t htmlLenght);
|
__attribute__((import_module("env"), import_name("setInnerHTML"))) void SetInnerHTML(std::int32_t ptr, const char* html, std::int32_t htmlLenght);
|
||||||
void SetInnerHTML(void* ptr, const std::string_view html) {
|
void SetInnerHTML(std::int32_t ptr, const std::string_view html) {
|
||||||
std::cout << "bind" << std::endl;
|
std::cout << "bind" << std::endl;
|
||||||
SetInnerHTML(ptr, html.data(), html.size());
|
SetInnerHTML(ptr, html.data(), html.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handling functions
|
// Event handling functions
|
||||||
__attribute__((import_module("env"), import_name("addClickListener"))) void AddClickListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addClickListener"))) void AddClickListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeClickListener"))) void RemoveClickListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeClickListener"))) void RemoveClickListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addMouseOverListener"))) void AddMouseOverListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addMouseOverListener"))) void AddMouseOverListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeMouseOverListener"))) void RemoveMouseOverListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeMouseOverListener"))) void RemoveMouseOverListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addMouseOutListener"))) void AddMouseOutListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addMouseOutListener"))) void AddMouseOutListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeMouseOutListener"))) void RemoveMouseOutListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeMouseOutListener"))) void RemoveMouseOutListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addMouseMoveListener"))) void AddMouseMoveListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addMouseMoveListener"))) void AddMouseMoveListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeMouseMoveListener"))) void RemoveMouseMoveListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeMouseMoveListener"))) void RemoveMouseMoveListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addMouseDownListener"))) void AddMouseDownListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addMouseDownListener"))) void AddMouseDownListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeMouseDownListener"))) void RemoveMouseDownListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeMouseDownListener"))) void RemoveMouseDownListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addMouseUpListener"))) void AddMouseUpListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addMouseUpListener"))) void AddMouseUpListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeMouseUpListener"))) void RemoveMouseUpListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeMouseUpListener"))) void RemoveMouseUpListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addFocusListener"))) void AddFocusListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addFocusListener"))) void AddFocusListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeFocusListener"))) void RemoveFocusListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeFocusListener"))) void RemoveFocusListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addBlurListener"))) void AddBlurListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addBlurListener"))) void AddBlurListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeBlurListener"))) void RemoveBlurListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeBlurListener"))) void RemoveBlurListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addKeyDownListener"))) void AddKeyDownListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addKeyDownListener"))) void AddKeyDownListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeKeyDownListener"))) void RemoveKeyDownListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeKeyDownListener"))) void RemoveKeyDownListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addKeyUpListener"))) void AddKeyUpListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addKeyUpListener"))) void AddKeyUpListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeKeyUpListener"))) void RemoveKeyUpListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeKeyUpListener"))) void RemoveKeyUpListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addKeyPressListener"))) void AddKeyPressListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addKeyPressListener"))) void AddKeyPressListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeKeyPressListener"))) void RemoveKeyPressListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeKeyPressListener"))) void RemoveKeyPressListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addChangeListener"))) void AddChangeListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addChangeListener"))) void AddChangeListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeChangeListener"))) void RemoveChangeListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeChangeListener"))) void RemoveChangeListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addSubmitListener"))) void AddSubmitListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addSubmitListener"))) void AddSubmitListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeSubmitListener"))) void RemoveSubmitListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeSubmitListener"))) void RemoveSubmitListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addInputListener"))) void AddInputListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addInputListener"))) void AddInputListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeInputListener"))) void RemoveInputListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeInputListener"))) void RemoveInputListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addResizeListener"))) void AddResizeListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addResizeListener"))) void AddResizeListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeResizeListener"))) void RemoveResizeListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeResizeListener"))) void RemoveResizeListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addScrollListener"))) void AddScrollListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addScrollListener"))) void AddScrollListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeScrollListener"))) void RemoveScrollListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeScrollListener"))) void RemoveScrollListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addContextMenuListener"))) void AddContextMenuListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addContextMenuListener"))) void AddContextMenuListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeContextMenuListener"))) void RemoveContextMenuListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeContextMenuListener"))) void RemoveContextMenuListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addDragStartListener"))) void AddDragStartListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addDragStartListener"))) void AddDragStartListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeDragStartListener"))) void RemoveDragStartListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeDragStartListener"))) void RemoveDragStartListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addDragEndListener"))) void AddDragEndListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addDragEndListener"))) void AddDragEndListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeDragEndListener"))) void RemoveDragEndListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeDragEndListener"))) void RemoveDragEndListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addDropListener"))) void AddDropListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addDropListener"))) void AddDropListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeDropListener"))) void RemoveDropListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeDropListener"))) void RemoveDropListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addWheelListener"))) void AddWheelListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addWheelListener"))) void AddWheelListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeWheelListener"))) void RemoveWheelListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeWheelListener"))) void RemoveWheelListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addDragOverListener"))) void AddDragOverListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addDragOverListener"))) void AddDragOverListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeDragOverListener"))) void RemoveDragOverListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeDragOverListener"))) void RemoveDragOverListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addDragEnterListener"))) void AddDragEnterListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addDragEnterListener"))) void AddDragEnterListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeDragEnterListener"))) void RemoveDragEnterListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeDragEnterListener"))) void RemoveDragEnterListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addDragLeaveListener"))) void AddDragLeaveListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("addDragLeaveListener"))) void AddDragLeaveListener(std::int32_t ptr, std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removeDragLeaveListener"))) void RemoveDragLeaveListener(void* ptr, int id);
|
__attribute__((import_module("env"), import_name("removeDragLeaveListener"))) void RemoveDragLeaveListener(std::int32_t ptr, std::int32_t id);
|
||||||
|
|
||||||
// Style functions
|
// Style functions
|
||||||
__attribute__((import_module("env"), import_name("setStyle"))) void SetStyle(void* ptr, const char* style, std::int32_t styleLength);
|
__attribute__((import_module("env"), import_name("setStyle"))) void SetStyle(std::int32_t ptr, const char* style, std::int32_t styleLength);
|
||||||
void SetStyle(void* ptr, const std::string_view style) {
|
void SetStyle(std::int32_t ptr, const std::string_view style) {
|
||||||
SetStyle(ptr, style.data(), style.size());
|
SetStyle(ptr, style.data(), style.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("setProperty"))) void SetProperty(void* ptr, const char* property, std::int32_t propertyLength, const char* value, std::int32_t valueLength);
|
__attribute__((import_module("env"), import_name("setProperty"))) void SetProperty(std::int32_t ptr, const char* property, std::int32_t propertyLength, const char* value, std::int32_t valueLength);
|
||||||
void SetProperty(void* ptr, const std::string_view property, const std::string_view value) {
|
void SetProperty(std::int32_t ptr, const std::string_view property, const std::string_view value) {
|
||||||
SetProperty(ptr, property.data(), property.size(), value.data(), value.size());
|
SetProperty(ptr, property.data(), property.size(), value.data(), value.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("addClass"))) void AddClass(void* ptr, const char* className, std::int32_t classNameLength);
|
__attribute__((import_module("env"), import_name("addClass"))) void AddClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||||
void AddClass(void* ptr, const std::string_view className) {
|
void AddClass(std::int32_t ptr, const std::string_view className) {
|
||||||
AddClass(ptr, className.data(), className.size());
|
AddClass(ptr, className.data(), className.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("removeClass"))) void RemoveClass(void* ptr, const char* className, std::int32_t classNameLength);
|
__attribute__((import_module("env"), import_name("removeClass"))) void RemoveClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||||
void RemoveClass(void* ptr, const std::string_view className) {
|
void RemoveClass(std::int32_t ptr, const std::string_view className) {
|
||||||
RemoveClass(ptr, className.data(), className.size());
|
RemoveClass(ptr, className.data(), className.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("toggleClass"))) void ToggleClass(void* ptr, const char* className, std::int32_t classNameLength);
|
__attribute__((import_module("env"), import_name("toggleClass"))) void ToggleClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||||
void ToggleClass(void* ptr, const std::string_view className) {
|
void ToggleClass(std::int32_t ptr, const std::string_view className) {
|
||||||
ToggleClass(ptr, className.data(), className.size());
|
ToggleClass(ptr, className.data(), className.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("hasClass"))) bool HasClass(void* ptr, const char* className, std::int32_t classNameLength);
|
__attribute__((import_module("env"), import_name("hasClass"))) bool HasClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||||
bool HasClass(void* ptr, const std::string_view className) {
|
bool HasClass(std::int32_t ptr, const std::string_view className) {
|
||||||
return HasClass(ptr, className.data(), className.size());
|
return HasClass(ptr, className.data(), className.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((import_module("env"), import_name("deleteElement"))) void DeleteElement(void* ptr);
|
__attribute__((import_module("env"), import_name("deleteElement"))) void DeleteElement(std::int32_t ptr);
|
||||||
|
|
||||||
// Value property functions
|
// Value property functions
|
||||||
__attribute__((import_module("env"), import_name("getValue"))) const char* GetValue(void* ptr);
|
__attribute__((import_module("env"), import_name("getValue"))) const char* GetValue(std::int32_t ptr);
|
||||||
__attribute__((import_module("env"), import_name("getPathName"))) const char* GetPathName();
|
__attribute__((import_module("env"), import_name("getPathName"))) const char* GetPathName();
|
||||||
__attribute__((import_module("env"), import_name("addPopStateListener"))) void AddPopStateListener(int id);
|
__attribute__((import_module("env"), import_name("addPopStateListener"))) void AddPopStateListener(std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("removePopStateListener"))) void RemovePopStateListener(int id);
|
__attribute__((import_module("env"), import_name("removePopStateListener"))) void RemovePopStateListener(std::int32_t id);
|
||||||
__attribute__((import_module("env"), import_name("pushState"))) void PushState(const char* data, std::int32_t dataLength, const char* title, std::int32_t titleLength, const char* url, std::int32_t urlLength);
|
__attribute__((import_module("env"), import_name("pushState"))) void PushState(const char* data, std::int32_t dataLength, const char* title, std::int32_t titleLength, const char* url, std::int32_t urlLength);
|
||||||
__attribute__((import_module("env"), import_name("setValue"))) void SetValue(void* ptr, const char* value, std::int32_t valueLength);
|
__attribute__((import_module("env"), import_name("setValue"))) void SetValue(std::int32_t ptr, const char* value, std::int32_t valueLength);
|
||||||
void SetValue(void* ptr, const std::string_view value) {
|
void SetValue(std::int32_t ptr, const std::string_view value) {
|
||||||
SetValue(ptr, value.data(), value.size());
|
SetValue(ptr, value.data(), value.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,40 +25,16 @@ import :BindingsImport;
|
||||||
import :EventTypes;
|
import :EventTypes;
|
||||||
|
|
||||||
namespace Crafter {
|
namespace Crafter {
|
||||||
export class HtmlElementView {
|
export class HtmlElementPtr {
|
||||||
public:
|
public:
|
||||||
void* ptr;
|
std::int32_t ptr;
|
||||||
std::vector<std::int32_t> clickHandlers;
|
HtmlElementPtr(const std::string_view id);
|
||||||
std::vector<std::int32_t> mouseOverHandlers;
|
HtmlElementPtr(const std::string_view id, const std::string_view html);
|
||||||
std::vector<std::int32_t> mouseOutHandlers;
|
HtmlElementPtr(HtmlElementPtr&&);
|
||||||
std::vector<std::int32_t> mouseMoveHandlers;
|
HtmlElementPtr(const HtmlElementPtr&) = delete;
|
||||||
std::vector<std::int32_t> mouseDownHandlers;
|
HtmlElementPtr& operator=(const HtmlElementPtr&) = delete;
|
||||||
std::vector<std::int32_t> mouseUpHandlers;
|
~HtmlElementPtr();
|
||||||
std::vector<std::int32_t> focusHandlers;
|
|
||||||
std::vector<std::int32_t> blurHandlers;
|
|
||||||
std::vector<std::int32_t> keyDownHandlers;
|
|
||||||
std::vector<std::int32_t> keyUpHandlers;
|
|
||||||
std::vector<std::int32_t> keyPressHandlers;
|
|
||||||
std::vector<std::int32_t> changeHandlers;
|
|
||||||
std::vector<std::int32_t> submitHandlers;
|
|
||||||
std::vector<std::int32_t> inputHandlers;
|
|
||||||
std::vector<std::int32_t> resizeHandlers;
|
|
||||||
std::vector<std::int32_t> scrollHandlers;
|
|
||||||
std::vector<std::int32_t> contextMenuHandlers;
|
|
||||||
std::vector<std::int32_t> dragStartHandlers;
|
|
||||||
std::vector<std::int32_t> dragEndHandlers;
|
|
||||||
std::vector<std::int32_t> dropHandlers;
|
|
||||||
std::vector<std::int32_t> dragOverHandlers;
|
|
||||||
std::vector<std::int32_t> dragEnterHandlers;
|
|
||||||
std::vector<std::int32_t> dragLeaveHandlers;
|
|
||||||
std::vector<std::int32_t> wheelHandlers;
|
|
||||||
|
|
||||||
HtmlElementView(const std::string_view id);
|
|
||||||
HtmlElementView(const std::string_view id, const std::string_view html);
|
|
||||||
HtmlElementView(HtmlElementView&&);
|
|
||||||
HtmlElementView(const HtmlElementView&) = delete;
|
|
||||||
HtmlElementView& operator=(const HtmlElementView&) = delete;
|
|
||||||
~HtmlElementView();
|
|
||||||
void SetInnerHTML(const std::string_view html);
|
void SetInnerHTML(const std::string_view html);
|
||||||
void SetStyle(const std::string_view style);
|
void SetStyle(const std::string_view style);
|
||||||
void SetProperty(const std::string_view property, const std::string_view value);
|
void SetProperty(const std::string_view property, const std::string_view value);
|
||||||
|
|
@ -67,7 +43,6 @@ namespace Crafter {
|
||||||
void ToggleClass(const std::string_view className);
|
void ToggleClass(const std::string_view className);
|
||||||
bool HasClass(const std::string_view className);
|
bool HasClass(const std::string_view className);
|
||||||
|
|
||||||
// Value property accessors
|
|
||||||
std::string GetValue();
|
std::string GetValue();
|
||||||
void SetValue(const std::string_view value);
|
void SetValue(const std::string_view value);
|
||||||
|
|
||||||
|
|
@ -144,13 +119,117 @@ namespace Crafter {
|
||||||
void RemoveWheelListener(std::int32_t id);
|
void RemoveWheelListener(std::int32_t id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export class HtmlElementView : public HtmlElementPtr {
|
||||||
|
public:
|
||||||
|
HtmlElementView(const std::string_view id);
|
||||||
|
HtmlElementView(const std::string_view id, const std::string_view html);
|
||||||
|
HtmlElementView(HtmlElementView&&);
|
||||||
|
~HtmlElementView();
|
||||||
|
|
||||||
|
std::int32_t AddClickListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||||
|
void RemoveClickListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddMouseOverListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||||
|
void RemoveMouseOverListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddMouseOutListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||||
|
void RemoveMouseOutListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddMouseMoveListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||||
|
void RemoveMouseMoveListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddMouseDownListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||||
|
void RemoveMouseDownListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddMouseUpListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||||
|
void RemoveMouseUpListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddFocusListener(std::function<void(Crafter::FocusEvent)> callback);
|
||||||
|
void RemoveFocusListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddBlurListener(std::function<void(Crafter::FocusEvent)> callback);
|
||||||
|
void RemoveBlurListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddKeyDownListener(std::function<void(KeyboardEvent)> callback);
|
||||||
|
void RemoveKeyDownListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddKeyUpListener(std::function<void(KeyboardEvent)> callback);
|
||||||
|
void RemoveKeyUpListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddKeyPressListener(std::function<void(KeyboardEvent)> callback);
|
||||||
|
void RemoveKeyPressListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddChangeListener(std::function<void(ChangeEvent)> callback);
|
||||||
|
void RemoveChangeListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddSubmitListener(std::function<void(void)> callback);
|
||||||
|
void RemoveSubmitListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddInputListener(std::function<void(InputEvent)> callback);
|
||||||
|
void RemoveInputListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddResizeListener(std::function<void(ResizeEvent)> callback);
|
||||||
|
void RemoveResizeListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddScrollListener(std::function<void(ScrollEvent)> callback);
|
||||||
|
void RemoveScrollListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddContextMenuListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveContextMenuListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddDragStartListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveDragStartListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddDragEndListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveDragEndListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddDropListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveDropListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddDragOverListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveDragOverListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddDragEnterListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveDragEnterListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddDragLeaveListener(std::function<void(MouseEvent)> callback);
|
||||||
|
void RemoveDragLeaveListener(std::int32_t id);
|
||||||
|
|
||||||
|
std::int32_t AddWheelListener(std::function<void(WheelEvent)> callback);
|
||||||
|
void RemoveWheelListener(std::int32_t id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::int32_t> clickHandlers;
|
||||||
|
std::vector<std::int32_t> mouseOverHandlers;
|
||||||
|
std::vector<std::int32_t> mouseOutHandlers;
|
||||||
|
std::vector<std::int32_t> mouseMoveHandlers;
|
||||||
|
std::vector<std::int32_t> mouseDownHandlers;
|
||||||
|
std::vector<std::int32_t> mouseUpHandlers;
|
||||||
|
std::vector<std::int32_t> focusHandlers;
|
||||||
|
std::vector<std::int32_t> blurHandlers;
|
||||||
|
std::vector<std::int32_t> keyDownHandlers;
|
||||||
|
std::vector<std::int32_t> keyUpHandlers;
|
||||||
|
std::vector<std::int32_t> keyPressHandlers;
|
||||||
|
std::vector<std::int32_t> changeHandlers;
|
||||||
|
std::vector<std::int32_t> submitHandlers;
|
||||||
|
std::vector<std::int32_t> inputHandlers;
|
||||||
|
std::vector<std::int32_t> resizeHandlers;
|
||||||
|
std::vector<std::int32_t> scrollHandlers;
|
||||||
|
std::vector<std::int32_t> contextMenuHandlers;
|
||||||
|
std::vector<std::int32_t> dragStartHandlers;
|
||||||
|
std::vector<std::int32_t> dragEndHandlers;
|
||||||
|
std::vector<std::int32_t> dropHandlers;
|
||||||
|
std::vector<std::int32_t> dragOverHandlers;
|
||||||
|
std::vector<std::int32_t> dragEnterHandlers;
|
||||||
|
std::vector<std::int32_t> dragLeaveHandlers;
|
||||||
|
std::vector<std::int32_t> wheelHandlers;
|
||||||
|
};
|
||||||
|
|
||||||
export class HtmlElement : public HtmlElementView {
|
export class HtmlElement : public HtmlElementView {
|
||||||
public:
|
public:
|
||||||
HtmlElement(const std::string_view id);
|
HtmlElement(const std::string_view id);
|
||||||
HtmlElement(const std::string_view id, const std::string_view html);
|
HtmlElement(const std::string_view id, const std::string_view html);
|
||||||
HtmlElement(HtmlElement&&);
|
HtmlElement(HtmlElement&&);
|
||||||
HtmlElement(const HtmlElement&) = delete;
|
|
||||||
HtmlElement& operator=(const HtmlElement&) = delete;
|
|
||||||
~HtmlElement();
|
~HtmlElement();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue