A lot of questions about DirectGui

Hi buddies

I’m making my game and it needs a lot of GUIs. Then i’m in a deep DirectGui workout :wink: … but a got a tons of questions about it.

  1. How to catch a mouseover/mouse out state of a direct button?
  2. There’s some way to make other guis bind other events … something like a DirectFrame binds a MouseClick or a Mouseover?
  3. how to access the items of DirectOptionMenu? I try customize it but i can’t find where they are (yes i see the source :slight_smile: ). When i use DirectOptionMenu.popupMenu.getChildren() i just got the nodepaths and i cannot cast it again in DirectButtons.


  1. IIRC
button.bind(DGG.WITHIN, self.mouseOver)
button.bind(DGG.WITHOUT, self.mouseOut)

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?

No idea, sorry :frowning:. I don’t use it.

In DirectGuiGlobals.py :

@coppertop and @ynjh_jo

Thanx about mouseover/mouseout tips. Work’s like a charm…

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:

# 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.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.

Phew …
Thanx 4 all