Skip to content
Otavio edited this page Dec 5, 2022 · 2 revisions

CWidgets::GetKey

What it does:

This functions returns the current key set/selected on the widget.

What it returns:

This function returns an unsigned int.

Usage:

This function can be used to get the current key that is set/selected on a widget.

Widgets:

List of widgets that are using this function:

  • Container
  • KeyBinder

Example:

Let's say I want to run a piece of code if the user is pressing the key selected on the KeyBinder:

if (FGUI::INPUT.IsKeyPressed(KeyBinder->GetKey()) {
  
  // the code will run when the user press the selected key on the KeyBinder.
  
}

// or

if (FGUI::INPUT.IsKeyHeld(KeyBinder->GetKey()) {
  
  // the code will run when the user holds the selected key on the KeyBinder.
  
}

What's next?

Next you will learn about the GetText function.