added view
This commit is contained in:
parent
5517a271c7
commit
580e53d3bc
11 changed files with 68 additions and 34 deletions
|
|
@ -8,7 +8,7 @@ using namespace Crafter;
|
|||
import std;
|
||||
|
||||
// Create the main container element
|
||||
HtmlElement* body = new HtmlElement("body", "<div id='container'>"
|
||||
HtmlElementView* body = new HtmlElementView("body", "<div id='container'>"
|
||||
"<h1>Enhanced Event Handling Demo</h1>"
|
||||
"<div id='events-container'>"
|
||||
"<div class='event-section'>"
|
||||
|
|
@ -58,22 +58,22 @@ HtmlElement* body = new HtmlElement("body", "<div id='container'>"
|
|||
"</div>");
|
||||
|
||||
// Get references to elements
|
||||
HtmlElement* mouseButton = new HtmlElement("mouseButton");
|
||||
HtmlElement* mouseOutput = new HtmlElement("mouseOutput");
|
||||
HtmlElement* keyInput = new HtmlElement("keyInput");
|
||||
HtmlElement* keyOutput = new HtmlElement("keyOutput");
|
||||
HtmlElement* focusInput = new HtmlElement("focusInput");
|
||||
HtmlElement* focusOutput = new HtmlElement("focusOutput");
|
||||
HtmlElement* formInput = new HtmlElement("formInput");
|
||||
HtmlElement* formSelect = new HtmlElement("formSelect");
|
||||
HtmlElement* formElement = new HtmlElement("formElement");
|
||||
HtmlElement* formOutput = new HtmlElement("formOutput");
|
||||
HtmlElement* windowOutput = new HtmlElement("windowOutput");
|
||||
HtmlElement* dragSource = new HtmlElement("dragSource");
|
||||
HtmlElement* dropTarget = new HtmlElement("dropTarget");
|
||||
HtmlElement* dragOutput = new HtmlElement("dragOutput");
|
||||
HtmlElement* wheelContainer = new HtmlElement("wheelContainer");
|
||||
HtmlElement* wheelOutput = new HtmlElement("wheelOutput");
|
||||
HtmlElementView* mouseButton = new HtmlElementView("mouseButton");
|
||||
HtmlElementView* mouseOutput = new HtmlElementView("mouseOutput");
|
||||
HtmlElementView* keyInput = new HtmlElementView("keyInput");
|
||||
HtmlElementView* keyOutput = new HtmlElementView("keyOutput");
|
||||
HtmlElementView* focusInput = new HtmlElementView("focusInput");
|
||||
HtmlElementView* focusOutput = new HtmlElementView("focusOutput");
|
||||
HtmlElementView* formInput = new HtmlElementView("formInput");
|
||||
HtmlElementView* formSelect = new HtmlElementView("formSelect");
|
||||
HtmlElementView* formElement = new HtmlElementView("formElement");
|
||||
HtmlElementView* formOutput = new HtmlElementView("formOutput");
|
||||
HtmlElementView* windowOutput = new HtmlElementView("windowOutput");
|
||||
HtmlElementView* dragSource = new HtmlElementView("dragSource");
|
||||
HtmlElementView* dropTarget = new HtmlElementView("dropTarget");
|
||||
HtmlElementView* dragOutput = new HtmlElementView("dragOutput");
|
||||
HtmlElementView* wheelContainer = new HtmlElementView("wheelContainer");
|
||||
HtmlElementView* wheelOutput = new HtmlElementView("wheelOutput");
|
||||
|
||||
int main() {
|
||||
// Mouse Events
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import Crafter.CppDOM;
|
|||
using namespace Crafter::CppDOM;
|
||||
|
||||
int main(){
|
||||
HtmlElement body("body");
|
||||
HtmlElementView body("body");
|
||||
body.SetInnerHTML("Hello World!");
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Crafter.CppDOM;
|
|||
using namespace Crafter;
|
||||
|
||||
int main(){
|
||||
HtmlElement body("body");
|
||||
HtmlElementView body("body");
|
||||
body.SetInnerHTML("Hello World!");
|
||||
//No need to call FreeJs, this is done in the destructor of HtmlElement.
|
||||
//No need to call FreeJs, this is done in the destructor of HtmlElementView.
|
||||
}
|
||||
|
|
@ -2,15 +2,15 @@ import Crafter.CppDOM;
|
|||
import std;
|
||||
using namespace Crafter;
|
||||
|
||||
HtmlElement body("body","<h1>Interactive Element Demo</h1>"
|
||||
HtmlElementView body("body","<h1>Interactive Element Demo</h1>"
|
||||
"<button id='myButton'>Click Me!</button>"
|
||||
"<p id='output'>Click the button above</p>");
|
||||
HtmlElement* button = new HtmlElement("myButton"); //prevent destruction
|
||||
HtmlElementView* button = new HtmlElement("myButton"); //prevent destruction
|
||||
|
||||
|
||||
int main() {
|
||||
button->AddClickListener([](Crafter::MouseEvent event){
|
||||
auto output = HtmlElement("output");
|
||||
auto output = HtmlElementView("output");
|
||||
output.SetInnerHTML("Button was clicked at (" + std::to_string(event.clientX) + ", " + std::to_string(event.clientY) + ")!");
|
||||
});
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@ import Crafter.CppDOM;
|
|||
using namespace Crafter;
|
||||
|
||||
int main(){
|
||||
HtmlElement body("body","<div id=\"myDiv\"></div>");
|
||||
HtmlElementView body("body","<div id=\"myDiv\"></div>");
|
||||
// Create a div element
|
||||
HtmlElement div("myDiv");
|
||||
HtmlElementView div("myDiv");
|
||||
|
||||
// Set some initial content
|
||||
div.SetInnerHTML("<p>This is a styled paragraph</p>");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue