# GUI Pointer Issues

**URL:** <https://forum.babylonjs.com/t/gui-pointer-issues/42577>\
**Category:** Questions\
**Tags:** gui\
**Created:** [July 20, 2023, 10:42am UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577 "2023-07-20T10:42:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrhermit](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vrhermit/32/35296_2.png) [@vrhermit](https://forum.babylonjs.com/u/vrhermit)\
**Post date:** [July 20, 2023, 10:42am UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/1 "2023-07-20T10:42:08Z")

</div>

I’ve run into an issue with GUI, perhaps because of what I’m trying to do.

I have a “main card window” card with several controls that will be interactive to open an additional card window. The control in the center of this card is a Rectangle with another control in side of it. The rectangle has `onPointerEnterObservable` and `onPointerOutObservable` events to create a hover effect.

The control is created in this file starting on line 93

> <https://github.com/radicalappdev/radical-canvatorium/blob/Lab047/utils/lab-examples.js>

When I click on the rectangle, I’m showing another plane with an ADT in front of the current one. That part works as expected, but because the new card appears in front of the old one, the `onPointerOutObservable` from the main card Rectangle never fires, leaving the control in a hovered state.

The issue starts when firing onPointerUpObservable on line 32

> <https://github.com/radicalappdev/radical-canvatorium/blob/Lab047/pages/labs/lab047.vue>

Also, I’m not sure if this is caused by the issue above or a separate issue, but _sometimes_ it is no longer possible to click on the rectangle after dismissing the modal card. Sometimes it works and sometimes I have to move the pointer and click elsewhere in the scene before trying again.

I’ve tried marking the ADT and the controls as dirty, but that didn’t help. I’ve also tried setting `focusedControl` to another control or to null.

Is there some other way to force a complete reset of the texture? Or a way to manually drop hover and focus from the rectangle?

You may be able to see the issue for yourself here. Click on the large rectangle with the description, then dismiss the modal that appears. Try it several times to see if it happens to you.  
[https://radical-canvatorium-git-lab047-radicalappdev.vercel.app/labs/lab047](https://radical-canvatorium-git-lab047-radicalappdev.vercel.app/labs/lab047)  
(edited link to Lab 047)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 20, 2023, 12:19pm UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/2 "2023-07-20T12:19:13Z")

</div>

Hello! Are you able to isolate the issue on the Playground? It will be easier to see what’s going on. I tried interacting with the example page, but I’m not seeing anything to dismiss the page that appears when I click one of the examples:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/2/928595cc12dd52c322cdcea11fa97337bbeb1258.jpeg)

Something that may work for your situation is simulating a pointer event with pick: [Babylon.js/packages/dev/gui/src/2D/advancedDynamicTexture.ts at master · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/gui/src/2D/advancedDynamicTexture.ts#L876)

---

<div class="post-metadata">

**Author:** ![vrhermit](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vrhermit/32/35296_2.png) [@vrhermit](https://forum.babylonjs.com/u/vrhermit)\
**Post date:** [July 20, 2023, 1:16pm UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/3 "2023-07-20T13:16:03Z")

</div>

Sorry, it looks like my link to the scene was wrong. It looks like you ended up at the lab template scene, but the problem is in Lab 047.

[https://radical-canvatorium-git-lab047-radicalappdev.vercel.app/labs/lab047](https://radical-canvatorium-git-lab047-radicalappdev.vercel.app/labs/lab047)

I haven’t tried to reproduce this on a playground yet as it would involve significant modification of the code.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 20, 2023, 1:50pm UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/4 "2023-07-20T13:50:19Z")

</div>

Oh thanks for the link! Can you try setting the modal’s `isPickable` property to false when you close it? This should allow the pick events to pass through it and hit the back plane.

---

<div class="post-metadata">

**Author:** ![vrhermit](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vrhermit/32/35296_2.png) [@vrhermit](https://forum.babylonjs.com/u/vrhermit)\
**Post date:** [July 20, 2023, 3:37pm UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/5 "2023-07-20T15:37:53Z")

</div>

You pointed me in the right direction. isPickable _should_ not be needed because the modal is supposed to be behind the card when it’s not active. The two cards are supposed to be switching positions. There was an error in my animation code that was placing the non-active modal card into the same z position of the active main card.

So that solves the picking issue, but the other issue remains.

When I click the rectangle on the main card, it still holds onto the hover state. When the modal card appears in front of the main, the `onPointerOutObservable` from the main card rectangle never fires, leaving the control in a hovered state.

On the rectangle, is there a way to call or force the `onPointerOutObservable` to run? Or a reliable way to “reset” the texture to its base state? I’ve tried `markAsDirty()` which doesn’t seem to do anything any more. That used to be my go-to method to reset an Advanced Dynamic Texture.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 20, 2023, 8:25pm UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/6 "2023-07-20T20:25:17Z")

</div>

> [@vrhermit](#):
>
> On the rectangle, is there a way to call or force the `onPointerOutObservable` to run?

You can make an observable fire by calling `observable.notifyObservers()`, so something like: [edff | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#HUYMNT#3) would work for you?

---

<div class="post-metadata">

**Author:** ![vrhermit](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vrhermit/32/35296_2.png) [@vrhermit](https://forum.babylonjs.com/u/vrhermit)\
**Post date:** [July 20, 2023, 8:48pm UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/7 "2023-07-20T20:48:08Z")

</div>

Ah! That is perfect! I didn’t know about notifyObservers. Thank you for all your help 😊

---

<div class="post-metadata">

**Author:** ![vrhermit](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vrhermit/32/35296_2.png) [@vrhermit](https://forum.babylonjs.com/u/vrhermit)\
**Post date:** [July 23, 2023, 10:58am UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/8 "2023-07-23T10:58:24Z")

</div>

Thanks again for the help on this @carolhmj

I just published this lab if you want to see it in action.

> **[Canvatorium Lab 047](https://vrhermit.com/scenes/canvatorium-lab-047/)**
>
> Open a modal card from the main window. The modal is contained in a window group with the main window.
> 
> 
> 
> 
> 
> 
> 
> This lab builds on Lab 046 by adding a modal windo

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [July 23, 2023, 11:28am UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/9 "2023-07-23T11:28:08Z")

</div>

That works pretty well. GJ 👍

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 24, 2023, 11:15am UTC](https://forum.babylonjs.com/t/gui-pointer-issues/42577/10 "2023-07-24T11:15:25Z")

</div>

Yes, it looks very nice! 😃
