Browse Source

Moving IFocusableControl to its own file.

Flux159 4 năm trước cách đây
mục cha
commit
a7bf0668c2

+ 2 - 31
gui/src/2D/advancedDynamicTexture.ts

@@ -16,42 +16,13 @@ import { Scene } from "babylonjs/scene";
 
 import { Container } from "./controls/container";
 import { Control } from "./controls/control";
+import { IFocusableControl } from './controls/focusableControl';
 import { Style } from "./style";
 import { Measure } from "./measure";
 import { Constants } from 'babylonjs/Engines/constants';
 import { Viewport } from 'babylonjs/Maths/math.viewport';
 import { Color3 } from 'babylonjs/Maths/math.color';
-/**
-* Interface used to define a control that can receive focus
-*/
-export interface IFocusableControl {
-    /**
-     * Function called when the control receives the focus
-     */
-    onFocus(): void;
-    /**
-     * Function called when the control loses the focus
-     */
-    onBlur(): void;
-    /**
-     * Function called to let the control handle keyboard events
-     * @param evt defines the current keyboard event
-     */
-    processKeyboard(evt: KeyboardEvent): void;
-    /**
-    * Function called to get the list of controls that should not steal the focus from this control
-    * @returns an array of controls
-    */
-    keepsFocusWith(): Nullable<Control[]>;
-    /**
-    * Function to focus the control programmatically
-    */
-    focus(): void;
-    /**
-    * Function to unfocus the control programmatically
-    */
-    blur(): void;
-}
+
 /**
 * Class used to create texture to support 2D GUI elements
 * @see https://doc.babylonjs.com/how_to/gui

+ 2 - 2
gui/src/2D/controls/focusableButton.ts

@@ -5,7 +5,7 @@ import { Button } from "./button";
 import { Control } from "./control";
 import { _TypeStore } from 'babylonjs/Misc/typeStore';
 import { PointerInfoBase } from 'babylonjs/Events/pointerEvents';
-import { IFocusableControl } from '../advancedDynamicTexture';
+import { IFocusableControl } from "./focusableControl";
 import { Observable } from 'babylonjs/Misc/observable';
 
 /**
@@ -89,7 +89,7 @@ export class FocusableButton extends Button implements IFocusableControl {
         // Clicking on button should focus
         this.focus();
 
-        super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
+        return super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
     }
 
     /** @hidden */

+ 34 - 0
gui/src/2D/controls/focusableControl.ts

@@ -0,0 +1,34 @@
+import { Nullable } from "babylonjs/types";
+import { Control } from "./control";
+
+/**
+* Interface used to define a control that can receive focus
+*/
+export interface IFocusableControl {
+    /**
+     * Function called when the control receives the focus
+     */
+    onFocus(): void;
+    /**
+     * Function called when the control loses the focus
+     */
+    onBlur(): void;
+    /**
+     * Function called to let the control handle keyboard events
+     * @param evt defines the current keyboard event
+     */
+    processKeyboard(evt: KeyboardEvent): void;
+    /**
+    * Function called to get the list of controls that should not steal the focus from this control
+    * @returns an array of controls
+    */
+    keepsFocusWith(): Nullable<Control[]>;
+    /**
+    * Function to focus the control programmatically
+    */
+    focus(): void;
+    /**
+    * Function to unfocus the control programmatically
+    */
+    blur(): void;
+}

+ 1 - 1
gui/src/2D/controls/inputText.ts

@@ -5,7 +5,7 @@ import { ClipboardEventTypes, ClipboardInfo } from "babylonjs/Events/clipboardEv
 import { PointerInfo, PointerEventTypes, PointerInfoBase } from 'babylonjs/Events/pointerEvents';
 
 import { Control } from "./control";
-import { IFocusableControl } from "../advancedDynamicTexture";
+import { IFocusableControl } from "./focusableControl";
 import { ValueAndUnit } from "../valueAndUnit";
 import { VirtualKeyboard } from "./virtualKeyboard";
 import { _TypeStore } from 'babylonjs/Misc/typeStore';