Преглед на файлове

added golden layout tab.onClose, fixed onBeforeClose when manually closing tab

Nicolas Cannasse преди 5 години
родител
ревизия
83af5944c8
променени са 3 файла, в които са добавени 8 реда и са изтрити 4 реда
  1. 3 0
      bin/libs/goldenlayout.js
  2. 3 4
      hide/ui/View.hx
  3. 2 0
      libs/golden/Tab.hx

+ 3 - 0
bin/libs/goldenlayout.js

@@ -2873,6 +2873,8 @@ lm.utils.copy( lm.controls.Tab.prototype, {
 		}
 	},
 
+	onClose : function() { return true; },
+
 	/**
 	 * Callback when the tab's close button is
 	 * clicked
@@ -2884,6 +2886,7 @@ lm.utils.copy( lm.controls.Tab.prototype, {
 	 */
 	_onCloseClick: function( event ) {
 		event.stopPropagation();
+		if( !this.onClose() ) return;
 		this.header.parent.removeChild( this.contentItem );
 	}
 } );

+ 3 - 4
hide/ui/View.hx

@@ -120,10 +120,6 @@ class View<T> extends hide.comp.Component {
 			onResize();
 		});
 		container.on("destroy",function(e) {
-			if( !onBeforeClose() ) {
-				try e.preventDefault() catch( _ : Dynamic ) {};
-				return;
-			}
 			destroy();
 		});
 		container.on("show", function(_) {
@@ -136,6 +132,9 @@ class View<T> extends hide.comp.Component {
 		});
 
 		container.on("tab", function(e) {
+			container.tab.onClose = function() {
+				return onBeforeClose();
+			};
 			container.tab.element.contextmenu(function(e) {
 				var menu = buildTabMenu();
 				if( menu.length > 0 ) new hide.comp.ContextMenu(menu);

+ 2 - 0
libs/golden/Tab.hx

@@ -6,4 +6,6 @@ extern class Tab {
 	public var header : Header;
 	public var element : js.jquery.JQuery;
 
+	dynamic function onClose() : Bool;
+
 }