input value example
This commit is contained in:
parent
b96faacf89
commit
3a45e25409
4 changed files with 36 additions and 1 deletions
17
examples/InputValueExample/main.cpp
Normal file
17
examples/InputValueExample/main.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Crafter.CppDOM;
|
||||
import std;
|
||||
using namespace Crafter;
|
||||
|
||||
|
||||
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>)");
|
||||
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("");
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue