Git Product home page Git Product logo

Comments (4)

ppizarror avatar ppizarror commented on June 12, 2024

Hello, if you don't want to use the menu.update(events), you must control which widget receives the events. For such purposes, you can use widget.is_selected(). For example:

import sys
import pygame
import pygame_menu

pygame.init()
screen = pygame.display.set_mode((1920, 1080))
clock = pygame.time.Clock()
menus = pygame_menu.Menu('', 1920, 1080, False)

age = menus.add.text_input(
    'Character age:',
)

name = menus.add.text_input(
    'Character name:'
)

menus.render()
menus._widget_selected_update = False

while True:
    events = pygame.event.get()
    for event in events:
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    screen.fill((255, 0, 0))
    menus.update(events)
    age.draw(screen)
    if age.is_selected():
        age.update(events)
    age.set_position(500, 500)

    name.draw(screen)
    if name.is_selected():
        name.update(events)
    name.set_position(500, 800)

    pygame.display.update()
    clock.tick(60)

Note that we must avoid Menu passing events to its widget, thus, we set menus._widget_selected_update = False.

from pygame-menu.

ppizarror avatar ppizarror commented on June 12, 2024

New version to be released today also adds the possibility to ignore the menu events for a single widget by changing receive_menu_update_events of a widget. For example:

name.receive_menu_update_events = False
menus.update(events)

In such a case name does not receive any input from menus.update.

from pygame-menu.

ppizarror avatar ppizarror commented on June 12, 2024

Version updated to v4.3.6. Let me know if this solves your issues,

from pygame-menu.

UltraRobot2017 avatar UltraRobot2017 commented on June 12, 2024

Yes, it helped me, thank you very much

from pygame-menu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.