I’m trying to incude some padding in a DirectLabel, and, well, it doesn’t seem to be working.
At the moment I don’t see anything that seems terribly likely to be interfering with things. Two points that might be of note are that I am immediately hiding my DirectLabel and that I frequently set its position in my update method. The final version is intended to also change its text, but, thinking that my call to “setFrameSize” might have been the reason that padding wasn’t working I commented out that functionality.
Excerpts from my code:
Initialisation:
# I've tried a variety of values in the "pad" parameter, I believe;
# the current, ridiculously high value is simply intended
# to clearly show whether it's working at all.
self.mouseOverLabel = DirectLabel(text="Kitten",
scale=0.07,
text_align=TextNode.ACenter,
text_fg=(0.45, 0.7, 1.0, 1),
text_bg=(0,0,0,1),
frameColor=(0, 0, 0, 0),
pad=(500,500))
self.mouseOverLabel.setBin(GUI_BIN, 0)
self.mouseOverLabel.hide()
self.lastMouseOver = None # Used to determine whether we should show and update the label
Update:
if base.mouseWatcherNode.hasMouse():
mouseX = base.mouseWatcherNode.getMouseX()
mouseY = base.mouseWatcherNode.getMouseY()
self.mouseOverLabel.setPos(render2d, mouseX, 0, mouseY-0.2)
selection = self.getSelectedObject(Point3(mouseX, 0, mouseY))
if selection is not self.lastMouseOver:
self.lastMouseOver = selection
if selection is None or isinstance(selection, LVecBase3) or isinstance(selection, SceneryRegion):
self.mouseOverLabel.hide()
else:
self.mouseOverLabel.show()
Any suggestions?
Further, once I reinstate the updating of the label’s text, will either the setting of the text (via 'self.mouseOverLabel[“text”] = ') or a subsequent call to ‘setFrameSize’ cause problems, and if so, what migh I do about that?