Events

Event(name:string)

모든 로블록스 이벤트들을 나타냅니다, MouseEnter, MouseLeave, MouseButton1Down, MouseButton1Up 등이 될 수 있습니다
기본적으로 로블록스의 기본 이벤트들과 다르게, 첫번째 인자로 self 를 받을 수 있습니다.

1
2
3
4
5
Frame {
    [Event "MouseEnter"] = function (self)
        print(self.Name .. "에 마우스가 올라왔습니다")
    end;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
local ScreenGUI = script.Parent
local Quad = require(path.to.module).Init()
local Class = Quad.Class
local Mount = Quad.Mount
local TextButton = Class "TextButton"

TextButton "mainButton" {
    Size = UDim2.fromOffset(200,200);
    [Event "MouseEnter"] = function (self)
        print("버튼이 클릭되었습니다")
    end;
}
Mount(ScreenGUI, Store.GetObject("mainButton"))

Event.Created

오브젝트가 생성되었을 때 실행됩니다. 첫번째 인자로 self 를 받을 수 있습니다.

1
2
3
4
5
6
-- 용법
Frame {
    [Event.Created] = function (self)
        print(self.Name .. "이 생성되었어요")
    end;
}

주의

Event.Created 가 실행될 때는 Parent 값이 정해지지 않았을 수 있습니다. self.Parent 는 접근해서는 안됩니다. Class.Extend 에서는 AfterRender 를 이용해야 합니다.


Event.CreatedAsync

Event.Created 와 비슷하지만, 코루틴 안에서 작동합니다. objectList:EachAsync() 처럼 반환을 기다리지 않습니다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
-- 용법
Frame {
    Frame {
        Name = "A";
        [Event.CreatedAsync] = function (self)
            -- 이 함수가 끝나지 않더라도 다음 오브젝트가 생성될 수 있어야합니다
            task.wait(5)
        end;
    };
    Frame {
        Name = "B";
        [Event.Created] = function (self)
            print(self.Name .. "가 생성되었습니다")
        end;
    };
}

주의

Event.CreatedAsync 가 실행될 때는 Parent 값이 정해지지 않았을 수 있습니다. self.Parent 는 접근해서는 안됩니다.


Event.Prop(propertyName:string)

프로퍼티 값이 변경됨을 연결합니다.

1
2
3
4
5
6
7
8
-- 용법
TextBox {
    Text = "아무거나 입력하세요";
    [Event.Prop "Text"] = function (self,text)
        -- 편의상의 이유로 변경된 값이 제공됩니다
        print(text)
    end;
}