bright-gpu-74537
03/25/2021, 10:09 PMcurved-appointment-82072
03/25/2021, 10:11 PMbright-gpu-74537
03/25/2021, 10:11 PMicy-zebra-52882
03/25/2021, 10:23 PMmain-view.xml but doesn't actually have any interaction with components in the source - all the interaction is in the form of onclick='some code here' on the buttons in the XMLicy-zebra-52882
03/25/2021, 10:24 PMclass MyClass extends Box|VBox|HBox)icy-zebra-52882
03/25/2021, 10:25 PMbright-gpu-74537
03/25/2021, 10:26 PMhaxeui create {backend} to create a custom view (MainView.hx) and use the xml therebright-gpu-74537
03/25/2021, 10:27 PMbright-gpu-74537
03/25/2021, 10:28 PMicy-zebra-52882
03/25/2021, 10:31 PM@:build in the new class I made, and changing (if i remember) var mainView:Component = new MainView() to var myClass:Component = new MyClass()icy-zebra-52882
03/25/2021, 10:31 PMicy-zebra-52882
03/25/2021, 10:32 PMbright-gpu-74537
03/25/2021, 10:32 PMbright-gpu-74537
03/25/2021, 10:33 PMicy-zebra-52882
03/25/2021, 10:33 PMnew HaxeUIApp or the MainView or how to do itbright-gpu-74537
03/25/2021, 10:35 PMbright-gpu-74537
03/25/2021, 10:36 PMicy-zebra-52882
03/25/2021, 10:38 PMonclick code and another that's reference by the .hx sourcebright-gpu-74537
03/25/2021, 10:38 PMicy-zebra-52882
03/25/2021, 10:39 PMbright-gpu-74537
03/25/2021, 10:39 PMicy-zebra-52882
03/25/2021, 10:43 PM// Build your layout
@:build(haxe.ui.macros.ComponentMacros.build("assets/generator.xml"))
// Class extends the root node of your layout
class Generator extends VBox {
public function new() {
super();
testLabel.show();
// Set testButton's onClick code
testButton.onClick = function(e) {
testLabel.hidden ? testLabel.show() : testLabel.hide();
}
}
my current example .hx class, if it helps, with the following XML:
<vbox width="100%" height="100%">
<vbox id="appBox" width="auto" horizontalAlign="center">
<button id="testButton" style="font-weight: bold" text="Click me!" />
<label id="testLabel" style="color: red;" text="Hello world!" />
</vbox>
</vbox>bright-gpu-74537
03/25/2021, 10:45 PMbright-gpu-74537
03/25/2021, 10:45 PMbright-gpu-74537
03/25/2021, 10:46 PMhaxe
package ;
import haxe.ui.HaxeUIApp;
class Main {
public static function main() {
var app = new HaxeUIApp();
app.ready(function() {
app.addComponent(new MainView());
app.start();
});
}
}bright-gpu-74537
03/25/2021, 10:46 PMbright-gpu-74537
03/25/2021, 10:46 PMhaxe
package ;
import haxe.ui.containers.VBox;
import haxe.ui.events.MouseEvent;
@:build(haxe.ui.macros.ComponentMacros.build("assets/main-view.xml"))
class MainView extends VBox {
public function new() {
super();
}
@:bind(myButton, MouseEvent.CLICK)
private function onMyButton(e:MouseEvent) {
myButton.text = "Thanks!";
}
}bright-gpu-74537
03/25/2021, 10:46 PMbright-gpu-74537
03/25/2021, 10:46 PMxml
<vbox style="padding: 5px;">
<style>
.button {
font-size: 24px;
}
</style>
<hbox>
<button text="Click Me!" id="myButton" />
<button text="Click Me Too!" onclick="this.text='Thanks!'" />
</hbox>
</vbox>bright-gpu-74537
03/25/2021, 10:46 PM