Toggle buttons need to go away with a new one

SolarPalSolarPal Posts: 2Member
edited August 23 in GUI




I want make tab-style menu. Only 1 tab should be opened at the time. Don't know how to implement it.

Answers

  • MegalomaniakMegalomaniak Posts: 2,898Admin

    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

  • GrampsGramps Posts: 40Member

    Are your buttons set with "toggle mode" on? I would modify the signals on each button to contain an additional argument which is the name of the button, that way your function knows which button called it.

    So each button should have signals like...
    _on_Squad_Toggled -> in extra arguments: String, "Squad"
    _on_Squad_Toggled -> in extra arguments: String, "Travel"
    ... and so on.

    Then change your function to something like:

    func _on_Squad_Toggled(button_pressed: bool, button: String) -> void:
        if button_pressed:
            move(Vector2(-720, 0))
            # Un-press all other buttons
            for M in $UI/Menu.get_children():
                if M != button:
                    M.set_pressed(false)
        else:
            move(Vector2(720,0))
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file