Comments (4)
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.
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.
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.
Yes, everything is working now. Thank you! Now, I can present a quality practical work to my teacher 🤩
from pygame-menu.
Related Issues (20)
- Python version limit HOT 2
- typehints (label) - mypy HOT 2
- [BUG] Menu closes for no reason HOT 5
- Resize all submenus HOT 3
- Unable to hide the cursor, due to pygame_menu HOT 3
- Controller has no influence on menu actions HOT 1
- Example of menu using USB controller, with name of controller used HOT 6
- pygame-ce requirement HOT 6
- file selector HOT 5
- How do I limit the size of a label in px? HOT 4
- Unpacking then repacking any widget misplaces it in the parent frame HOT 1
- Add method to dropselect API that tells if its dropdown is expanded
- Have a _sdl2 mode where make_surface is never called whith alpha=True
- Navigating back from a nested submenu forgets the widget selection in the parent menu HOT 2
- User warning for equal title font color and menu background color when the latter is set to (0, 0, 0) HOT 2
- How check value for text_input? HOT 1
- AttributeError when changing rangeslider value with an USB gamepad
- bug in windows HOT 2
- Sub-menus not working if you create a menu class inheriting from pygame_menu.Menu
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygame-menu.