diff --git a/examples/InputValueExample/main.cpp b/examples/InputValueExample/main.cpp new file mode 100644 index 0000000..247199a --- /dev/null +++ b/examples/InputValueExample/main.cpp @@ -0,0 +1,17 @@ +import Crafter.CppDOM; +import std; +using namespace Crafter; + + +HtmlElement* body = new HtmlElement("body", R"(

Input GetValue() and SetValue() Example



)"); +HtmlElement* button = new HtmlElement("button"); +HtmlElement* output = new HtmlElement("valueOutput"); +HtmlElement* input = new HtmlElement("input"); + +int main(){ + button->AddClickListener([](Crafter::MouseEvent) { + std::string newValue = input->GetValue(); + output->SetInnerHTML(newValue); + input->SetValue(""); + }); +} \ No newline at end of file diff --git a/examples/InputValueExample/project.json b/examples/InputValueExample/project.json new file mode 100644 index 0000000..9750e20 --- /dev/null +++ b/examples/InputValueExample/project.json @@ -0,0 +1,17 @@ +{ + "name": "main", + "configurations": [ + { + "name": "executable", + "implementations": ["main"], + "target": "wasm32-wasi", + "debug" : true, + "dependencies": [ + { + "path":"../../project.json", + "configuration":"lib-debug" + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/InputValueExample/run.sh b/examples/InputValueExample/run.sh new file mode 100755 index 0000000..e706621 --- /dev/null +++ b/examples/InputValueExample/run.sh @@ -0,0 +1 @@ +caddy file-server --listen :8080 --root bin/executable \ No newline at end of file diff --git a/implementations/Crafter.CppDOM-HtmlElement.cpp b/implementations/Crafter.CppDOM-HtmlElement.cpp index e8e98ec..c43c678 100644 --- a/implementations/Crafter.CppDOM-HtmlElement.cpp +++ b/implementations/Crafter.CppDOM-HtmlElement.cpp @@ -66,7 +66,7 @@ namespace Crafter { const char* value = CppDOMBindings::GetValue(ptr); if(value != nullptr) { std::string result(value); - std::free(value); + std::free(const_cast(value)); return result; } else { return "";