66'use strict' ;
77
88import 'vs/css!./button' ;
9- import { EventEmitter } from 'vs/base/common/eventEmitter' ;
109import DOM = require( 'vs/base/browser/dom' ) ;
1110import { Builder , $ } from 'vs/base/browser/builder' ;
1211import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
1312import { KeyCode } from 'vs/base/common/keyCodes' ;
1413import { Color } from 'vs/base/common/color' ;
1514import { mixin } from 'vs/base/common/objects' ;
15+ import Event , { Emitter } from 'vs/base/common/event' ;
1616
1717export interface IButtonOptions extends IButtonStyles {
1818}
@@ -30,7 +30,7 @@ const defaultOptions: IButtonStyles = {
3030 buttonForeground : Color . white
3131} ;
3232
33- export class Button extends EventEmitter {
33+ export class Button {
3434
3535 private $el : Builder ;
3636 private options : IButtonOptions ;
@@ -40,11 +40,12 @@ export class Button extends EventEmitter {
4040 private buttonForeground : Color ;
4141 private buttonBorder : Color ;
4242
43+ private _onDidClick = new Emitter < any > ( ) ;
44+ readonly onDidClick : Event < any > = this . _onDidClick . event ;
45+
4346 constructor ( container : Builder , options ?: IButtonOptions ) ;
4447 constructor ( container : HTMLElement , options ?: IButtonOptions ) ;
4548 constructor ( container : any , options ?: IButtonOptions ) {
46- super ( ) ;
47-
4849 this . options = options || Object . create ( null ) ;
4950 mixin ( this . options , defaultOptions , false ) ;
5051
@@ -64,14 +65,14 @@ export class Button extends EventEmitter {
6465 return ;
6566 }
6667
67- this . emit ( DOM . EventType . CLICK , e ) ;
68+ this . _onDidClick . fire ( e ) ;
6869 } ) ;
6970
7071 this . $el . on ( DOM . EventType . KEY_DOWN , ( e ) => {
7172 let event = new StandardKeyboardEvent ( e as KeyboardEvent ) ;
7273 let eventHandled = false ;
7374 if ( this . enabled && event . equals ( KeyCode . Enter ) || event . equals ( KeyCode . Space ) ) {
74- this . emit ( DOM . EventType . CLICK , e ) ;
75+ this . _onDidClick . fire ( e ) ;
7576 eventHandled = true ;
7677 } else if ( event . equals ( KeyCode . Escape ) ) {
7778 this . $el . domBlur ( ) ;
@@ -165,7 +166,5 @@ export class Button extends EventEmitter {
165166 this . $el . dispose ( ) ;
166167 this . $el = null ;
167168 }
168-
169- super . dispose ( ) ;
170169 }
171170}
0 commit comments