# Switching tabs in GUI (SOLVED)

**URL:** <https://forum.defold.com/t/switching-tabs-in-gui-solved/58564>\
**Category:** Questions\
**Created:** [July 26, 2019, 12:10pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564 "2019-07-26T12:10:03Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [July 26, 2019, 12:10pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/1 "2019-07-26T12:10:04Z")

</div>

I would like to create a GUI like that:

 ![inv3](https://forum-defold-uploads.b-cdn.net/original/3X/b/c/bc340558af1291b8ab4678bfa3d5839d4239891f.png)

I’m trying to utilize Gooey and Monarch, and tried to create a main “pause” gui which has the buttons representing the tabs and also an exit button. Then, on the top of that there could be a popup for current tab - like on the image, there is some inventory gui below tabs.

The problem is, when I `monarch.show(hash("inventory")` the “pause” gui below loses its input focus and I can’t click on other buttons nor exit button.

I can create each gui with the tabs above, and paste a code handling those buttons in each of those gui, but that’s not an elegant solution. I do want to have a one gui with background and tabs buttons and exit button below each gui representing inventory, quest log, etc.

What do you think would be better approach? 🙂

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 26, 2019, 12:28pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/2 "2019-07-26T12:28:27Z")

</div>

Ah, interesting problem! I guess the “pause” gui could maybe reacquire input focus after you navigate to one of the sub-screens. A bit hackish maybe…

Or maybe I could add an option to Monarch that allows you to flag a screen to keep focus when navigating to the next screen.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [July 26, 2019, 12:58pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/3 "2019-07-26T12:58:05Z")

</div>

> [@britzl](#):
>
> Or maybe I could add an option to Monarch that allows you to flag a screen to keep focus when navigating to the next screen.

That would be great! 😃

> [@britzl](#):
>
> reacquire input focus

That is a good solution too, I will try it!

Also, if it comes to Monarch - the _“Timestep Below Popup”_ was always confusing for me, because I would like to have different timesteps below different popups, so I was always thinking that this sets the timestep for a screen below the actual popup - for example: I don’t want the time to be stopped when being in “dialog” popup, but would like to stop time, while being in this “pause menu” popup. So I thought that I would set _timestep to 0 below popup called pause_ and _timestep to 1 below popup called dialog_, but as you know it works totally different - so, what do you think about my approach?

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [July 26, 2019, 3:30pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/4 "2019-07-26T15:30:58Z")

</div>

Actually releasing input focus from “inventory” popup and reacquiring it in “pause” gui is a bad solution, because I cannot then operate with Inventory 😃 so probably I will end up with one gui containing all the tabs guis and switching their position to the center of the screen when they’re needed and just enabling them and disabling the rest, but that would be a mess in the Editor 😕

Is it possible to have two guis acquiring input?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [July 26, 2019, 6:42pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/5 "2019-07-26T18:42:27Z")

</div>

Yes. Return true if you consume the input

> **[API reference (GUI)](https://defold.com/ref/gui/)**
>
> Defold is a free and open game engine used for development of console, desktop, mobile and web games.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [July 28, 2019, 2:35pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/6 "2019-07-28T14:35:23Z")

</div>

> ## Nesting screens
> 
> Sometimes it might be desirable to have a screen that contains one or more sub-screens or children, for instance popups that are used only by that screen. Monarch supports nested screens only when the parent screen is created via a collection factory. If the parent screen is loaded via a collection proxy the sub/child-screens won’t be able to receive any input.

What about that option in Monarch? It seems like it could resolve that particular issue 😃

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 28, 2019, 3:39pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/7 "2019-07-28T15:39:33Z")

</div>

> [@Pawel](#):
>
> What about that option in Monarch? It seems like it could resolve that particular issue

That describes the case where a screen contains other screens and how you can use Monarch to interact with those sub-screens. It doesn’t really solve your case of keeping input active on multiple screens at the same time.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 1, 2019, 1:47pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/8 "2019-08-01T13:47:45Z")

</div>

> [@britzl](#):
>
> add an option to Monarch that allows you to flag a screen to keep focus when navigating to the next screen.

@Pawel This has been implemented on a branch. Could you please give it a try?

[https://github.com/britzl/monarch/issues/48](https://github.com/britzl/monarch/issues/48)

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [August 2, 2019, 5:56am UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/9 "2019-08-02T05:56:58Z")

</div>

Yes, I will try this today, thank you very much! 😉

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [August 4, 2019, 1:04pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/10 "2019-08-04T13:04:00Z")

</div>

I tried, but my entire project wasn’t working and I didn’t know why. I found out, that the Defold-Input has also changed and my code for handling input wasn’t working anymore 😕

```
mapper.bind(mapper.KEY_LEFT, "left", 1)

```

This was not working because there is no more KEY\_LEFT in the mapper (in/mapper) 😕

How to bind it now?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 4, 2019, 1:19pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/11 "2019-08-04T13:19:57Z")

</div>

> [@Pawel](#):
>
> This was not working because there is no more KEY\_LEFT in the mapper (in/mapper) 😕
> 
> How to bind it now?

Are you depending upon master.zip? You should never do that. Always depend upon a [specific release](https://github.com/britzl/defold-input/releases) to prevent problems with library dependencies introducing breaking changes .

As for your specific problem: The constants have been moved to triggers.lua in 2.0.0+.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [August 4, 2019, 2:34pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/12 "2019-08-04T14:34:24Z")

</div>

I’m aware of that, but also, when I’m developing I would like to have a newest version. Thanks for the answer! 😉 And thank you very much for the improvement in Monarch - it works as I imagined! 😃

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 4, 2019, 2:37pm UTC](https://forum.defold.com/t/switching-tabs-in-gui-solved/58564/13 "2019-08-04T14:37:24Z")

</div>

> [@Pawel](#):
>
> And thank you very much for the improvement in Monarch - it works as I imagined

Good to hear! Thank you for confirming that it works for you.
