https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • b

    bright-gpu-74537

    06/20/2020, 10:56 AM
    not sure in kha... i guess you could override the renderTo method
  • b

    bright-gpu-74537

    06/20/2020, 10:56 AM
    yeah, that should work, i mean it would only work for kha ofc
  • b

    bright-gpu-74537

    06/20/2020, 10:57 AM
    its an interesting point though, going to have a play to see if thats accurate
  • f

    fast-rain-20339

    06/20/2020, 10:57 AM
    No worries, not up to that yet 🙂
  • b

    bright-gpu-74537

    06/20/2020, 10:57 AM
    cool - gonna have a mess around anyway
  • b

    bright-gpu-74537

    06/20/2020, 11:20 AM
    Copy code
    haxe
    class MyComponent extends Box {
        public var lastSelection:String = null;
        
        public function new() {
            super();
            registerEvent(MouseEvent.CLICK, onViewClick);
        }
        
        public override function renderTo(g:Graphics) {
            if (this.isReady == false || this.hidden == true) {
                return;
            }
            
            g.color = Color.Blue;
            g.fillRect(screenX, screenY, this.width / 2, this.height / 2);
            g.color = Color.White;
            
            g.color = Color.Yellow;
            g.fillRect(screenX + this.width / 2, screenY, this.width / 2, this.height / 2);
            g.color = Color.White;
            
            g.color = Color.Red;
            g.fillRect(screenX, screenY + this.height / 2, this.width / 2, this.height / 2);
            g.color = Color.White;
            
            g.color = Color.Green;
            g.fillRect(screenX + this.width / 2, screenY + this.height / 2, this.width / 2, this.height / 2);
            g.color = Color.White;
        }
        
        private function onViewClick(event:MouseEvent) {
            var x = event.localX;
            var y = event.localY;
            var cx = this.width;
            var cy = this.height;
            if (x < cx / 2 && y < cy / 2) {
                lastSelection = "blue";
                dispatch(new UIEvent(UIEvent.CHANGE));
            } else if (x > cx / 2 &&  y < cy / 2) {
                lastSelection = "yellow";
                dispatch(new UIEvent(UIEvent.CHANGE));
            } else if (x < cx / 2 && y > cy / 2) {
                lastSelection = "red";
                dispatch(new UIEvent(UIEvent.CHANGE));
            } else if (x > cx / 2 && y > cy / 2) {
                lastSelection = "green";
                dispatch(new UIEvent(UIEvent.CHANGE));
            }
        }
    }
  • b

    bright-gpu-74537

    06/20/2020, 11:20 AM
    Copy code
    xml
    <vbox style="padding: 5px;">
        <button text="Click Me!" onclick="c.width += 20; c.height += 20;" />
        <my-component id="c" width="100" height="100" onchange="sel.text = this.lastSelection" />
        <label id="sel" text="Select something!" />
    </vbox>
  • b

    bright-gpu-74537

    06/20/2020, 11:21 AM
    ^^ @User
  • f

    fast-rain-20339

    06/20/2020, 11:21 AM
    ooooh!!
  • f

    fast-rain-20339

    06/20/2020, 11:22 AM
    This is fabulous, thanks for the awesome example!
  • b

    bright-gpu-74537

    06/20/2020, 11:22 AM
    no worries, wanted to see if it was as doable as i assumed 🙂
  • f

    fast-rain-20339

    06/20/2020, 11:23 AM
    I hadn't thought about how I'd join all my UI code together, I haven't seen
    dispatch(new UIEvent
    before, that looks clean. Reminds me of using web frameworks like react or vue
  • c

    clever-oil-61353

    06/20/2020, 12:05 PM
    Think i'm gonna tell my kids that learning how to work with gl shaders is alot of fun and see if one of em actually looks into it.
  • f

    fast-rain-20339

    06/20/2020, 12:06 PM
    Aha how old are they? I'm not a gl expert but it's fun to tweak shadertoy code 😄
  • c

    clever-oil-61353

    06/20/2020, 12:08 PM
    keep in mind if you ask me ages again in a week, the numbers may vary by a digit lol..... but,,,, i believe 11, 13, 14 is the youngest 3. something like 22 and 25 on the oldest two. My wife is asleep, otherwise i would ask to make sure lol
  • f

    fast-rain-20339

    06/20/2020, 12:08 PM
    oh haha fair enough
  • c

    clever-oil-61353

    06/20/2020, 12:09 PM
    The older two are out doing their own thing in other states, don't hear from them often.
  • b

    bright-gpu-74537

    06/20/2020, 12:10 PM
    wait, what? How many kids you got??
  • f

    fast-rain-20339

    06/20/2020, 12:10 PM
    I count five 😛
  • c

    clever-oil-61353

    06/20/2020, 12:10 PM
    lol
  • f

    fast-rain-20339

    06/20/2020, 12:10 PM
    I am 19 🙂
  • c

    clever-oil-61353

    06/20/2020, 12:10 PM
    i was wrong, 13, 14, is actually 14, 15..... the only girl we have is the 14 yr old
  • b

    bright-gpu-74537

    06/20/2020, 12:11 PM
    yeah, i got 5, but thought there might be more between "youngest" and "oldest"
  • b

    bright-gpu-74537

    06/20/2020, 12:11 PM
    "just" five then?
  • c

    clever-oil-61353

    06/20/2020, 12:11 PM
    lol Ian
  • c

    clever-oil-61353

    06/20/2020, 12:11 PM
    yeah, just 5
  • b

    bright-gpu-74537

    06/20/2020, 12:11 PM
    😮
  • b

    bright-gpu-74537

    06/20/2020, 12:11 PM
    and here i am stressing out about a single noisey puppy 😄
  • c

    clever-oil-61353

    06/20/2020, 12:11 PM
    lol
  • c

    clever-oil-61353

    06/20/2020, 12:14 PM
    you need 5 puppies, so they are fighting over their toys constantly and running through the house, and steadily yapping at ya.
1...292293294...1687Latest