You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is.
When UIButton is disable, it cannot responds to click event. This is expected behavior. However, it should change its text even it is disabled.
To Reproduce
Steps to reproduce the behaviour:
Sample code:
import pygame
import pygame_gui
# Initialize pygame
pygame.init()
# Set up the display
window_size = (800, 600)
window_surface = pygame.display.set_mode(window_size)
pygame.display.set_caption('Button Click Example')
# Set up the GUI manager
manager = pygame_gui.UIManager(window_size)
# Create buttons
button1 = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((300, 275), (200, 50)),
text='0',
manager=manager)
button2 = pygame_gui.elements.UIButton(relative_rect=pygame.Rect((300, 350), (200, 50)),
text='Toggle Button1',
manager=manager)
# Variables to track button1 state
button1_click_count = 0
button1_enabled = True
# Main loop
clock = pygame.time.Clock()
is_running = True
while is_running:
time_delta = clock.tick(60) / 1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
if event.type == pygame.USEREVENT:
if event.user_type == pygame_gui.UI_BUTTON_PRESSED:
if event.ui_element == button1:
button1_click_count += 1
button1.set_text(str(button1_click_count))
elif event.ui_element == button2:
button1_enabled = not button1_enabled
button1.disable() if not button1_enabled else button1.enable() # !!! BUG, the disabled button1 never changed its disabled text caption
manager.process_events(event)
manager.update(time_delta)
window_surface.fill((0, 0, 0))
manager.draw_ui(window_surface)
pygame.display.update()
pygame.quit()
When I click button1, its number will increase by 1.
When I click button2 to disable button1, the button always keep the number when the button1 is first disabled. I hope when the button1 is enabled and disabled multiple times, button1's disabled text is the last text when button1 is enabled.
Expected behaviour
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Platform and software (please complete the following information):
Describe the bug
A clear and concise description of what the bug is.
When UIButton is disable, it cannot responds to click event. This is expected behavior. However, it should change its text even it is disabled.
To Reproduce
Steps to reproduce the behaviour:
Sample code:
Expected behaviour
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Platform and software (please complete the following information):
Additional context
Add any other context about the problem here.
I change the following code, and the behavior is my expected:
But I am not sure my change is appropriate for the whole library. Please verify the bug and fix it.
The text was updated successfully, but these errors were encountered: