Skip to content

Commit

Permalink
Fix text input visibility when its custom object is hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H committed Oct 21, 2024
1 parent bde7e18 commit 6211da4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Extensions/TextInput/textinputruntimeobject-pixi-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,25 @@ 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(
Expand All @@ -141,6 +156,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,
Expand Down
4 changes: 4 additions & 0 deletions GDJS/Runtime/CustomRuntimeObjectInstanceContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ namespace gdjs {
return this._runtimeScene;
}

getOwner() {
return this._customObject;
}

getAsyncTasksManager(): AsyncTasksManager {
return this._runtimeScene.getAsyncTasksManager();
}
Expand Down

0 comments on commit 6211da4

Please sign in to comment.