Remove selected on blur event

This commit is contained in:
Damien Vitrac
2019-12-06 16:27:11 +01:00
parent a0f9051aa7
commit d07abc6c7e
2 changed files with 13 additions and 3 deletions

View File

@@ -20,7 +20,7 @@
[resizerRight]="'#paper-container'">
</div>
<flo-editor-paper tabindex="0" (onDelete)="deleteSelected()"
<flo-editor-paper tabindex="0" (onDelete)="deleteSelected()" (onBlur)="editorContext.selection = null"
(onProperties)="onPropertiesHandle()">
<div id="paper" class="paper" tabindex="0" style="overflow: hidden; position: absolute; display: block; height:100%; width:100%; overflow:auto;"></div>
<ng-content select="[canvas]"></ng-content>

View File

@@ -1,7 +1,7 @@
import {
Component,
ElementRef, EventEmitter,
HostListener,
HostListener, OnInit,
Output,
ViewChild,
ViewEncapsulation
@@ -16,7 +16,7 @@ import {
styleUrls: ['./editor.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class PaperComponent {
export class PaperComponent implements OnInit {
@ViewChild('paper', { static: true }) paperElement: ElementRef;
@@ -26,6 +26,9 @@ export class PaperComponent {
@Output()
onProperties = new EventEmitter<number>();
@Output()
onBlur = new EventEmitter<boolean>();
@HostListener('click')
click() {
this.paperElement.nativeElement.focus();
@@ -51,4 +54,11 @@ export class PaperComponent {
this.onProperties.emit();
}
ngOnInit(): void {
const onBlur = this.onBlur;
this.paperElement.nativeElement.addEventListener('blur', () => {
onBlur.emit();
});
}
}