haxeui / haxeui-heaps

MIT License
31 stars 12 forks source link

Wrong mouse events #15

Closed kevinresol closed 4 years ago

kevinresol commented 4 years ago
package;

import haxe.ui.events.MouseEvent;
import haxe.ui.*;
import haxe.ui.core.*;
import haxe.ui.components.*;
import haxe.ui.containers.*;

class Main extends hxd.App {

    static function main() {
        new Main();
    }

    override function init() {
        hxd.Res.initEmbed();
        Toolkit.init({app: this});
        var root = new VBox();
        Screen.instance.addComponent(root);

        var window = hxd.Window.getInstance();
        root.width = window.width;
        root.height = window.height;
        root.customStyle.backgroundColor = 0x37344C;

        var box = new Box();
        root.addComponent(box);
        box.customStyle.width = 100;
        box.customStyle.height = 100;
        box.customStyle.backgroundColor = 0xff0000;
        box.registerEvent(MouseEvent.MOUSE_OVER, _ -> trace('mouse over'));
        box.registerEvent(MouseEvent.MOUSE_MOVE, _ -> trace('mouse move'));
        box.registerEvent(MouseEvent.MOUSE_OUT, _ -> trace('mouse out'));
    }
}

When moving mouse on the box and then out of it, will trace the following:

src/Main.hx:32: mouse over
src/Main.hx:32: mouse over
src/Main.hx:32: mouse over
src/Main.hx:34: mouse out

But expected to be:

src/Main.hx:32: mouse over
src/Main.hx:32: mouse move
src/Main.hx:32: mouse move
src/Main.hx:34: mouse out