Browse Source

Closure event test.

pull/50/head
Rafal Kupiec 2 years ago
parent
commit
ad3c6e6d7e
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 42 additions and 0 deletions
  1. +41
    -0
      tests/closure_event.aer
  2. +1
    -0
      tests/closure_event.exp

+ 41
- 0
tests/closure_event.aer View File

@ -0,0 +1,41 @@
class Button {
public callback $OnBeforeClick;
public callback $OnAfterClick;
public string $Name;
public void __construct() {
$this->Name = 'MyButton';
}
public void Click() {
$this->DoBeforeClick();
print('Click!');
$this->DoAfterClick();
}
private void DoBeforeClick() {
if($this->OnBeforeClick) {
callback $event = $this->OnBeforeClick;
$event($this);
}
}
private void DoAfterClick() {
if($this->OnAfterClick) {
callback $event = $this->OnAfterClick;
$event($this);
}
}
}
class Program {
void main() {
object $MyWidget = new Button();
$MyWidget->OnBeforeClick = void(object $Sender) { print($Sender->Name + ' (Before Click)'); };
$MyWidget->OnAfterClick = void(object $Sender) { print($Sender->Name + ' (After Click)'); };
$MyWidget->Click();
}
}

+ 1
- 0
tests/closure_event.exp View File

@ -0,0 +1 @@
MyButton (Before Click)Click!MyButton (After Click)

Loading…
Cancel
Save