Revision Difference
ui-events-and-input#547735
<cat>Dev.UI</cat>
<title>Events and Input</title>
## Panel Events & Input
# Events
Panels can listen for events, here's the current list:
| Event | Description |
|-------------------|-----|
| onclick | Called when left clicking on a panel |
| onmiddleclick | Called when middle clicking on a panel |
| onrightclick | Called when right clicking on a panel |
| onmousedown | Called when any mouse button is pressed this frame |
| onmouseup | Called when any mouse button is released this frame |
| ondoubleclick | Called when a panel is double clicked on |
| onmousemove | Called every frame where your mouse is moving inside of a panel |
| onmouseover | Called when your mouse enters the bounds of a panel |
| onmouseout | Called when your mouse exits the bounds of a panel |
| onfocus | Called when the panel comes into focus |
| onblur | Called when the panel loses focus |
| onback | Called when you click the Back button on your mouse |
| onforward | Called when you click the Forward button on your mouse |
**Warning**: events will only work on the first root panel you create.
**Warning**: You may have to disable pointer events on overlapping transparent GUI elements for events to trigger!
## Usage
```csharp
panel.AddEventListener( "onclick", e => Log.Info( "I clicked my panel!" ) );
```
# Class Overrides
All panels have these available virtual methods for you to override, if you choose not to use events.
```csharp
protected virtual void OnClick( MousePanelEvent e )
protected virtual void OnMiddleClick( MousePanelEvent e )
protected virtual void OnRightClick( MousePanelEvent e )
protected virtual void OnMouseDown( MousePanelEvent e )
protected virtual void OnMouseUp( MousePanelEvent e )
protected virtual void OnMouseMove( MousePanelEvent e )
protected virtual void OnDoubleClick( MousePanelEvent e )
protected virtual void OnMouseOver( MousePanelEvent e )
protected virtual void OnMouseOut( MousePanelEvent e )
protected virtual void OnBack( PanelEvent e )
protected virtual void OnForward( PanelEvent e )
protected virtual void OnFocus( PanelEvent e )
protected virtual void OnBlur( PanelEvent e )
```