Events

Events in CactusGUI are triggered for events that Pygame recieves in your game loop. CatusGUI's event listener sends the event to a CactusGUI element based on coordinates and focus. An element's events can be bound to a function with one parameter (which stores the name of the element - helpful if you want a function that can be called by more than one element).

Example Code:


gui['elementNameHere'].style( use_click=True )

def myNewFunction( element_name ):
	# some code here
	pass
	
def myOtherNewFunction( element_name ):
	# some code here
	pass

gui['elementNameHere'].events( onClick=myNewFunction, onRightClick=myOtherNewFunction )

Info for Events:

Listener Areas needed for Events:
Event Requires Comments
onHover use_hover  
onUnhover use_hover  
onMousedown use_click  
onRightMousedown use_click  
onAnyMousedown use_click  
onMouseup use_click  
onRightMouseup use_click  
onAnyMouseup use_click  
onClick use_click  
onRightClick use_click  
onAnyClick use_click  
onCenterMouseup use_scroll  
onCenterMousedown use_scroll  
onScrollUp use_scroll  
onScrollDown use_scroll  
onEnter   Used by states
onExit   Used by states
onActivate use_click & use_active  
onDeactivate use_click  
onFocus use_click & use_focus  
onBlur use_click  
onKeydown None Works with any focused element or the current state

Does not currectly work on Textboxes or Keybinds
(right now they use the event to make themselves work)
Elements' Default Listener Areas:
Element Default Listeners Comments
Blank Element None  
State None  
Background None  
Rectangle None  
Image None  
Label None  
Textbox use_click, use_focus Problem:
Avoid using onKeydown
(Element currently uses it itself)
Button use_click, use_active, use_hover  
Keybind use_click, use_focus Problem:
Avoid using onKeydown
(Element currently uses it itself)
Point None