Hello,
I want to build a complex button which combines multiple texts and images for each of the states. I’ve figured out that the “geom” attribute can be used for this, however I’d like to know the best approaches…
Should I use OnScreenText/OnScreenImages reparented to a DirectFrame, for each state?
Or parented just to a regular NodePath?
Or should I avoid OnScreenText/OnScreenImages and use DirectFrames or other DirectGUI objects for each sub element, setting their “image” and “text” attributes?
Which of these approaches fits best with the GUI system?
At the moment I’ve been attempting as shown below, and it kind of works, however the items I create seem to get duplicated for the button. (So there are double the images/texts overlaying each other).
highLightedButtonGeom = DirectFrame()
obj = OnscreenText(text = "Example", font = fontBlurred, fg = Vec4(0.75,1,0,1), pos = (0,0.25), scale = 0.15)
obj.reparentTo(highLightedButtonGeom)
obj = OnscreenText(text = "Example", font = font, fg = Vec4(0.5,0.75,0,1), pos = (0,0.25), scale = 0.15)
obj.reparentTo(highLightedButtonGeom)
obj = OnscreenImage("menuitem-highlighted.png", scale = (scale_y,1,scale_y))
obj.reparentTo(highLightedButtonGeom)
regularButtonGeom = DirectFrame()
obj = OnscreenText(text = "Example", font = font, fg = Vec4(0.5,0.75,0,1), pos = (0,0.25), scale = 0.15)
obj.reparentTo(regularButtonGeom)
obj = OnscreenImage("menuitem-regular.png", scale = (scale_y,1,scale_y))
obj.reparentTo(regularButtonGeom)
button = DirectButton(relief = None, pressEffect = 0, geom = (regularButtonGeom,highLightedButtonGeom,highLightedButtonGeom,regularButtonGeom))