Skip to content

Commit

Permalink
Merge pull request #7935 from davisb10/master
Browse files Browse the repository at this point in the history
Add ContextMenu onShow / onHide events. Closes #7934
  • Loading branch information
cagataycivici committed Jul 23, 2019
2 parents efa2a7f + 2f3dd85 commit e9df9cb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/components/contextmenu/contextmenu.ts
@@ -1,4 +1,4 @@
import { NgModule, Component, ElementRef, AfterViewInit, OnDestroy, Input, Output, Renderer2, Inject, forwardRef, ViewChild, NgZone } from '@angular/core';
import { NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,Renderer2,Inject,forwardRef,ViewChild,NgZone,EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DomHandler } from '../dom/domhandler';
import { MenuItem } from '../common/menuitem';
Expand Down Expand Up @@ -152,6 +152,10 @@ export class ContextMenu implements AfterViewInit, OnDestroy {

@Input() triggerEvent: string = 'contextmenu';

@Output() onShow: EventEmitter<any> = new EventEmitter();

@Output() onHide: EventEmitter<any> = new EventEmitter();

@ViewChild('container', { static: false }) containerViewChild: ElementRef;

documentClickListener: any;
Expand Down Expand Up @@ -195,11 +199,14 @@ export class ContextMenu implements AfterViewInit, OnDestroy {
if (event) {
event.preventDefault();
}

this.onShow.emit({});
}

hide() {
this.containerViewChild.nativeElement.style.display = 'none';
this.unbindGlobalListeners();
this.onHide.emit({});
}

moveOnTop() {
Expand Down
25 changes: 25 additions & 0 deletions src/app/showcase/components/contextmenu/contextmenudemo.html
Expand Up @@ -155,6 +155,31 @@ <h3>Properties</h3>
</tbody>
</table>
</div>

<h3>Events</h3>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Parameters</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>onShow</td>
<td>event: Event object</td>
<td>Callback to invoke when context menu is shown.</td>
</tr>
<tr>
<td>onHide</td>
<td>event: Event object</td>
<td>Callback to invoke when context menu is hidden.</td>
</tr>
</tbody>
</table>
</div>

<h3>Methods</h3>
<div class="doc-tablewrapper">
Expand Down

0 comments on commit e9df9cb

Please sign in to comment.