I’m making my game and it needs a lot of GUIs. Then i’m in a deep DirectGui workout … but a got a tons of questions about it.
How to catch a mouseover/mouse out state of a direct button?
There’s some way to make other guis bind other events … something like a DirectFrame binds a MouseClick or a Mouseover?
how to access the items of DirectOptionMenu? I try customize it but i can’t find where they are (yes i see the source ). When i use DirectOptionMenu.popupMenu.getChildren() i just got the nodepaths and i cannot cast it again in DirectButtons.
I’m not sure what you mean. Do you want a frame to be clickable? I don’t think that’s possible, but that’s what DirectButton is for. Why would you want to have other stuff react to mouse events?
Thanx about mouseover/mouseout tips. Work’s like a charm…
@coppertop
I really don’t want a frame clickable, but a frame sensible to mouserover/mouseout to manage focus.
I already solve my problem and i’ll share if someone stuck in the same point.
A: all right, already solved by coppertop and ynjh_jo: DirectButton().bind(DGG,WITHIN) to mouseover and DirectButton().bind(DGG.WITHOUT) to mouseout
Yes! That’s the way:
aframe=DirectFrame(...)
# guiItem is a attribute of almost all DirectGui's
# it's a PGItem (or PGButton or else). The PGItem is
# responsable for listen mouse and react to events
# sometimes itś inactive, just active it and be happy
# listen any mouse events :-)
aframe.guiItem.setActive(True)
aframe.bind(DGG.WITHOUT, mouseOutCallback)
aframe.bind(DGG.WITHIN, mouseOverCallback)
aframe.bind(DGG.B1PRESS, frameClickCallback) #yes ... a frame clickable :-0
All items in DirectOptionMenu are DirectButtons. When you call DirectOptionMenu()[‘items’] it return all labels and not the DirectButtons.
The true items are in DirectOptionMenu().component(‘item%d’) where the %d is the integer of index of element in DirectOptionMenu()[‘items’].
At the moment at creation of a DirectOptionMenu for every label in DirectOptionMenu()[‘items’] is created a DirectButton in DirectOptionMenu().component(‘item%d’) in 1 to 1 relationship.