mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Popup menu at button midpoint
This commit is contained in:
parent
ae58253ec6
commit
db8f2ba387
@ -172,14 +172,9 @@ class DirectOptionMenu(DirectButton):
|
|||||||
# Compute bounds
|
# Compute bounds
|
||||||
b = self.getBounds()
|
b = self.getBounds()
|
||||||
fb = self.popupMenu.getBounds()
|
fb = self.popupMenu.getBounds()
|
||||||
# Where did the user click his mouse?
|
# Position menu at midpoint of button
|
||||||
if (base.mouseWatcherNode.hasMouse()):
|
xPos = (b[1] - b[0])/2.0 - fb[0]
|
||||||
xPos = base.mouseWatcherNode.getMouseX()
|
self.popupMenu.setX(self, xPos)
|
||||||
self.popupMenu.setX(render2d, xPos)
|
|
||||||
else:
|
|
||||||
# If no mouse watcher, use midpoint of menu button
|
|
||||||
xPos = (b[1] - b[0])/2.0 - fb[0]
|
|
||||||
self.popupMenu.setX(self, xPos)
|
|
||||||
# Try to set height to line up selected item with button
|
# Try to set height to line up selected item with button
|
||||||
self.popupMenu.setZ(
|
self.popupMenu.setZ(
|
||||||
self, self.minZ + (self.selectedIndex + 1)*self.maxHeight)
|
self, self.minZ + (self.selectedIndex + 1)*self.maxHeight)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user