Git Product home page Git Product logo

Comments (4)

ppizarror avatar ppizarror commented on June 11, 2024 1

Thank you for quick reply! Now, mouse hover on the menu is displayed correctly. However, I'm still facing the problem with clicks that are only registered within the left_surface and not on the actual menu.

Hi, I forgot to propagate the offset to the events. See the updated PR, which now works for all widgets 😄

from pygame-menu.

ppizarror avatar ppizarror commented on June 11, 2024

Hi, I never considered that a Menu would be drawn on a subsurface; thus, the (300, 0) offset was not taken into account while retrieving the widget's real position within the window.

Thus, #464 implements a menu surface value, which now remembers the last offset value used to draw the Menu. Your example should work without any change; also, providing the surface value to the Menu constructor also helps:

import pygame as pg
import pygame_menu as pgm

pg.init()
w, h = 500, 500
left_surf_w, left_surf_h = 300, h
menu_w, menu_h = 200, h

main_surface = pg.display.set_mode((w, h))
left_surface = main_surface.subsurface((0, 0, left_surf_w, left_surf_h))
menu_surface = main_surface.subsurface((300, 0, menu_w, menu_h))
menu = pgm.Menu("Bug menu", menu_w, menu_h,
                mouse_motion_selection=True,
                theme=pgm.themes.THEME_SOLARIZED,
                position=(0, 0),
                surface=menu_surface)
menu.add.button("Button")
menu.add.button("Button")
menu.add.button("Button")
menu.add.button("Button")
menu.add.button("Button")

while True:
    events = pg.event.get()
    for event in events:
        if event.type == pg.QUIT:
            pg.quit()
            exit()
    menu.update(events)
    menu.draw()
    left_surface.fill((255, 255, 0))
    pg.display.flip()

Let me know if the new PR solves your issue

from pygame-menu.

OverLeo007 avatar OverLeo007 commented on June 11, 2024

Thank you for quick reply! Now, mouse hover on the menu is displayed correctly. However, I'm still facing the problem with clicks that are only registered within the left_surface and not on the actual menu.

from pygame-menu.

OverLeo007 avatar OverLeo007 commented on June 11, 2024

Yes, everything is working now. Thank you! Now, I can present a quality practical work to my teacher 🤩

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.