本文整理匯總了TypeScript中vs/base/browser/builder.Builder.on方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Builder.on方法的具體用法?TypeScript Builder.on怎麽用?TypeScript Builder.on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/base/browser/builder.Builder
的用法示例。
在下文中一共展示了Builder.on方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setContainer
public setContainer(container: HTMLElement): void {
if (this.$el) {
this.$el.off(['click', 'mousedown']);
this.$el = null;
}
if (container) {
this.$el = $(container);
this.$el.on('mousedown', (e: MouseEvent) => this.onMouseDown(e));
}
}
示例2: constructor
constructor(container: HTMLElement, options: IBaseDropdownOptions) {
super();
this.toDispose = [];
this.$el = $('.dropdown').appendTo(container);
this.$label = $('.dropdown-label');
if (options.tick || options.action) {
this.$label.addClass('tick');
}
let labelRenderer = options.labelRenderer;
if (!labelRenderer && options.action) {
this.$action = $('.dropdown-action').appendTo(this.$el);
let item = new ActionItem(null, options.action, {
icon: true,
label: true
});
item.actionRunner = this;
item.render(this.$action.getHTMLElement());
labelRenderer = (container: HTMLElement): IDisposable => {
container.innerText = '';
return item;
};
}
if (!labelRenderer) {
labelRenderer = (container: HTMLElement): IDisposable => {
$(container).text(options.label || '');
return null;
};
}
this.$label.on(['mousedown', EventType.Tap], (e: Event) => {
e.preventDefault();
e.stopPropagation();
this.toggleDropdown();
}).appendTo(this.$el);
let cleanupFn = labelRenderer(this.$label.getHTMLElement());
if (cleanupFn) {
this.toDispose.push(cleanupFn);
}
this.toDispose.push(new Gesture(this.$label.getHTMLElement()));
}
示例3: constructor
constructor(container: any) {
super();
this.$el = $('a.monaco-button').href('#').appendTo(container);
this.$el.on('click', (e) => {
if (!this.enabled) {
DOM.EventHelper.stop(e);
return;
}
this.emit('click', e);
});
}
示例4: constructor
constructor(container: HTMLElement, options: IBaseDropdownOptions) {
super();
this._toDispose = [];
this.$el = $('.monaco-dropdown').appendTo(container);
this.$label = $('.dropdown-label');
let labelRenderer = options.labelRenderer;
if (!labelRenderer) {
labelRenderer = (container: HTMLElement): IDisposable => {
$(container).text(options.label || '');
return null;
};
}
this.$label.on([EventType.CLICK, EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
EventHelper.stop(e, true); // prevent default click behaviour to trigger
}).on([EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
if (e instanceof MouseEvent && e.detail > 1) {
return; // prevent multiple clicks to open multiple context menus (https://github.com/Microsoft/vscode/issues/41363)
}
if (this.visible) {
this.hide();
} else {
this.show();
}
}).appendTo(this.$el);
let cleanupFn = labelRenderer(this.$label.getHTMLElement());
if (cleanupFn) {
this._toDispose.push(cleanupFn);
}
Gesture.addTarget(this.$label.getHTMLElement());
}
示例5: constructor
constructor(container: HTMLElement, options: IBaseDropdownOptions) {
super();
this._toDispose = [];
this.$el = $('.dropdown').appendTo(container);
this.$label = $('.dropdown-label');
let labelRenderer = options.labelRenderer;
if (!labelRenderer) {
labelRenderer = (container: HTMLElement): IDisposable => {
$(container).text(options.label || '');
return null;
};
}
this.$label.on([EventType.CLICK, EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
EventHelper.stop(e, true); // prevent default click behaviour to trigger
}).on([EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
// We want to show the context menu on dropdown so that as a user you can press and hold the
// mouse button, make a choice of action in the menu and release the mouse to trigger that
// action.
// Due to some weird bugs though, we delay showing the menu to unwind event stack
// (see https://github.com/Microsoft/vscode/issues/27648)
setTimeout(() => this.show(), 100);
}).appendTo(this.$el);
let cleanupFn = labelRenderer(this.$label.getHTMLElement());
if (cleanupFn) {
this._toDispose.push(cleanupFn);
}
this._toDispose.push(new Gesture(this.$label.getHTMLElement()));
}