---
name: "SoButtonEvent"
section: "3"
platform: "linux"
package: "coin"
version: "1:4.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SoButtonEvent"
---

# SoButtonEvent(3)

The SoButtonEvent class is the base class for all button events.

## NAME

SoButtonEvent - The **SoButtonEvent** class is the base class for all button events.

## SYNOPSIS

\#include \<Inventor/events/SoButtonEvent.h\>

Inherits **SoEvent**.

Inherited by **SoKeyboardEvent**, **SoMouseButtonEvent**, and **SoSpaceballButtonEvent**.

### Public Types

enum **State** { **UP**, **DOWN**, **UNKNOWN** }\

### Public Member Functions

virtual **SoType** **getTypeId** (void) const\
 **SoButtonEvent** (void)\
 virtual **~SoButtonEvent** ()\
 void **setState** (**State** state)\
 **State** **getState** (void) const\

Public Member Functions inherited from **SoEvent** **SoEvent** (void)\
 virtual **~SoEvent** ()\
 SbBool **isOfType** (**SoType** type) const\
 void **setTime** (const **SbTime** t)\
 **SbTime** **getTime** (void) const\
 void **setPosition** (const **SbVec2s** &p)\
 const **SbVec2s** & **getPosition** (void) const\
 const **SbVec2s** & **getPosition** (const **SbViewportRegion** &vpRgn) const\
 const **SbVec2f** & **getNormalizedPosition** (const **SbViewportRegion** &vpRgn) const\
 void **setShiftDown** (SbBool isDown)\
 SbBool **wasShiftDown** (void) const\
 void **setCtrlDown** (SbBool isDown)\
 SbBool **wasCtrlDown** (void) const\
 void **setAltDown** (SbBool isDown)\
 SbBool **wasAltDown** (void) const\

### Static Public Member Functions

static **SoType** **getClassTypeId** (void)\
 static void **initClass** (void)\
 static SbBool **enumToString** (**State** enumval, **SbString** &stringrep)\

Static Public Member Functions inherited from **SoEvent** static **SoType** **getClassTypeId** (void)\
 static void **initClass** (void)\

## Detailed Description

The **SoButtonEvent** class is the base class for all button events.

The event classes which results from the user pushing buttons on some device (keyboard, mouse or spaceball) all inherit this class. The **SoButtonEvent** class contains methods for setting and getting the state of the button(s).

**See also**

**SoEvent**, **SoKeyboardEvent**, **SoMouseButtonEvent**, **SoSpaceballButtonEvent**

**SoEventCallback**, **SoHandleEventAction**

## Member Enumeration Documentation

### enum SoButtonEvent::State

This gives the actual state of the button.

**Enumerator**

- ***UP***

  Button has been released.

- ***DOWN***

  Button has been pressed down.

- ***UNKNOWN***

  The state of the button is unknown.

## Constructor & Destructor Documentation

### SoButtonEvent::SoButtonEvent (void )

Constructor.

### SoButtonEvent::~SoButtonEvent () \[virtual\]

Destructor.

## Member Function Documentation

### SoType SoButtonEvent::getClassTypeId (void ) \[static\]

This static method returns the **SoType** object associated with objects of this class.

### SoType SoButtonEvent::getTypeId (void ) const \[virtual\]

Returns the type identification of an object derived from a class inheriting **SoEvent**. This is used for runtime type checking and "downward" casting.

Reimplemented from **SoEvent**.

Reimplemented in **SoKeyboardEvent**, **SoMouseButtonEvent**, and **SoSpaceballButtonEvent**.

### void SoButtonEvent::initClass (void ) \[static\]

Initialize the type information data.

### void SoButtonEvent::setState (SoButtonEvent::State state)

Set the state of the button which the user interacted with.

This method is used from the window specific device classes when translating events to the generic Coin library.

**See also**

**getState()**

### SoButtonEvent::State SoButtonEvent::getState (void ) const

Returns the state of the button which is the cause of the event, i.e. whether it was pushed down or released.

**See also**

**wasShiftDown()**, **wasCtrlDown()**, **wasAltDown()**, **getPosition()**, **getTime()**

### SbBool SoButtonEvent::enumToString (State enumval, SbString & stringrep) \[static\]

Converts from an enum value of type **SoButtonEvent::State** to a string containing the enum symbol.

This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.\
 **Since**

Coin 3.0

## Author

Generated automatically by Doxygen for Coin from the source code.
