Skip to content

Commit 3963713

Browse files
committed
Add listener
1 parent 3e7684c commit 3963713

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/app/app.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ import { Component } from '@angular/core';
66
<window title="Angular app in window!">
77
<text [style.font-size.px]="45">Hello, {{ name }}</text>
88
9-
<button [style.background-color]="'green'">
9+
<button [style.background-color]="'green'" (clicked)="setName()">
1010
Green button
1111
</button>
1212
</window>
1313
`
1414
})
1515
export class AppComponent {
1616
public name = 'World!';
17+
18+
setName() {
19+
this.name = 'irustm';
20+
}
1721
}

src/lib/renderer.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ import {
55
RendererStyleFlags2,
66
RendererType2
77
} from '@angular/core';
8-
import {
9-
QWidget,
10-
QPushButton,
11-
QLabel,
12-
FlexLayout,
13-
QMainWindow
14-
} from '@nodegui/nodegui';
8+
import { QMainWindow, NativeEvent } from '@nodegui/nodegui';
159
import { QWindowService } from './window';
1610
import { NgWindow } from './components/window';
1711
import { NgComponent } from './components/component';
@@ -96,7 +90,11 @@ export class NodeguiRenderer implements Renderer2 {
9690
eventName: string,
9791
callback: (event: any) => boolean | void
9892
): () => void {
99-
return () => {};
93+
const callbackFunc = (e: NativeEvent) => callback.call(target, e);
94+
95+
target.addEventListener(eventName, callbackFunc);
96+
97+
return () => target.removeEventListener(eventName, callbackFunc);
10098
}
10199

102100
nextSibling(node: any): any {

0 commit comments

Comments
 (0)