Skip to content
Update to new event system authored by Moritz Brückner's avatar Moritz Brückner
...@@ -61,9 +61,8 @@ package; ...@@ -61,9 +61,8 @@ package;
import koui.Koui; import koui.Koui;
import koui.elements.*; import koui.elements.*;
import koui.events.EventHandler;
import koui.events.Events; import koui.events.Events;
import koui.events.MouseEvent.MouseClickEvent;
class Main { class Main {
public static function main() { public static function main() {
...@@ -76,11 +75,11 @@ class Main { ...@@ -76,11 +75,11 @@ class Main {
var button = new Button("Click me!"); var button = new Button("Click me!");
button.setPosition(400, 180); button.setPosition(400, 180);
button.onMouseClick(function(e: Event) { button.addEventListener(MouseClickEvent, (e: MouseClickEvent) -> {
switch (e.state) { switch (e.getState()) {
case Active: case ClickHold:
button.label = "Clicking"; button.label = "Clicking";
case Deactivated: case ClickEnd:
button.label = "Clicked"; button.label = "Clicked";
default: default:
button.label = "Click me!"; button.label = "Click me!";
...@@ -112,8 +111,7 @@ package arm; ...@@ -112,8 +111,7 @@ package arm;
import koui.Koui; import koui.Koui;
import koui.elements.*; import koui.elements.*;
import koui.events.EventHandler; import koui.events.MouseEvent.MouseClickEvent;
import koui.events.Events;
class KouiTrait extends iron.Trait { class KouiTrait extends iron.Trait {
public function new() { public function new() {
...@@ -124,11 +122,11 @@ class KouiTrait extends iron.Trait { ...@@ -124,11 +122,11 @@ class KouiTrait extends iron.Trait {
var button = new Button("Click me!"); var button = new Button("Click me!");
button.setPosition(400, 180); button.setPosition(400, 180);
button.onMouseClick(function(e: Event) { button.addEventListener(MouseClickEvent, (e: MouseClickEvent) -> {
switch (e.state) { switch (e.getState()) {
case Active: case ClickHold:
button.label = "Clicking"; button.label = "Clicking";
case Deactivated: case ClickEnd:
button.label = "Clicked"; button.label = "Clicked";
default: default:
button.label = "Click me!"; button.label = "Click me!";
... ...
......