Fix text input visibility when its custom object is hidden (#7089)

This commit is contained in:
D8H
2024-10-21 12:41:47 +02:00
committed by GitHub
parent bde7e1896d
commit 0383f8a7e1
2 changed files with 26 additions and 4 deletions
@@ -129,10 +129,27 @@ namespace gdjs {
// Hide the input entirely if the layer is not visible.
// Because this object is rendered as a DOM element (and not part of the PixiJS
// scene graph), we have to do this manually.
const layer = this._instanceContainer.getLayer(this._object.getLayer());
if (!layer.isVisible()) {
this._input.style.display = 'none';
return;
{
let instanceContainer = this._instanceContainer;
let object: gdjs.RuntimeObject = this._object;
let hasParent = true;
do {
const layer = instanceContainer.getLayer(object.getLayer());
if (!layer.isVisible() || !object.isVisible()) {
this._input.style.display = 'none';
return;
}
// TODO Declare an interface to move up in the object tree.
if (
instanceContainer instanceof
gdjs.CustomRuntimeObjectInstanceContainer
) {
object = instanceContainer.getOwner();
instanceContainer = object.getInstanceContainer();
} else {
hasParent = false;
}
} while (hasParent);
}
const workingPoint: FloatPoint = gdjs.staticArray(
@@ -141,6 +158,7 @@ namespace gdjs {
const runtimeGame = this._instanceContainer.getGame();
const runtimeGameRenderer = runtimeGame.getRenderer();
const layer = this._instanceContainer.getLayer(this._object.getLayer());
const topLeftCanvasCoordinates = layer.convertInverseCoords(
this._object.x,
this._object.y,
@@ -290,6 +290,10 @@ namespace gdjs {
return this._runtimeScene;
}
getOwner(): gdjs.CustomRuntimeObject {
return this._customObject;
}
getAsyncTasksManager(): AsyncTasksManager {
return this._runtimeScene.getAsyncTasksManager();
}