Text similar to a DirectButton

I’m trying to create some text that acts like a DirectButton in that when the mouse rolls over it, the text will show up, but not actually have a button there. I have a normal DirectButton to which I parented a gui model, but if I try to change the button’s text, the text renders under the gui model, which isn’t what I want. (I’ve tried messing with the sortOrder and parenting, but I still get the same result.) This is why I wanted to create a seperate text widget (in the same position as my button) and have a statement where text will appear when you rollover it. This sort of idea popped into my head:

if mouse in myButton.bounds:
    text.show()

^ Is there anything similar to that?

When you create a DirectButton you can tell it to have different text for all its states, and one of its state is ‘rollover’ -that is when the mouse pointer is over the button.
As per manual:

b = DirectButton(text = ("OK", "click!", "rolling over", "disabled"))

If you need more control you can the within and without (mouse-over) events of any active direct gui element to a custom function

ui.bind(DGG.WITHIN, self.mouseOver)
ui.bind(DGG.WITHOUT, self.mouseOut)

Make sure your function accepts a extra argument because the function will be called with a ‘gui event’ argument (mouse pos and something like that).

Additionally, if you want to get rid of the visible button, try passing in the keyword parameter “relief”, with a value of either “DGG.FLAT” or “None”–something like this:

btn = DirectButton(text = ("OK", "click!", "rolling over", "disabled"), relief = DGG.FLAT)

Thank you very much, wezu, the bind() function was exactly what I was looking for. Works great. :smiley: