Gooey GUI Library
Loading...
Searching...
No Matches
gooey_textbox.h File Reference
#include "common/gooey_common.h"
#include <stdbool.h>

Go to the source code of this file.

Functions

GooeyTextbox * GooeyTextBox_Create (int x, int y, int width, int height, char *placeholder, void(*onTextChanged)(char *text))
 Adds a textbox to the window.
 
void GooeyTextbox_Draw (GooeyWindow *win)
 Draws the textbox on the window.
 
bool GooeyTextbox_HandleClick (GooeyWindow *win, int x, int y)
 Handles textbox click events.
 
void GooeyTextbox_HandleKeyPress (GooeyWindow *win, void *event)
 Handles key press events for the textbox.
 
const char * GooeyTextbox_GetText (GooeyTextbox *textbox)
 Gets the text of the textbox.
 
void GooeyTextbox_SetText (GooeyTextbox *textbox, const char *text)
 Sets the text of the textbox.
 

Function Documentation

◆ GooeyTextBox_Create()

GooeyTextbox * GooeyTextBox_Create ( int  x,
int  y,
int  width,
int  height,
char *  placeholder,
void(*)(char *text)  onTextChanged 
)

Adds a textbox to the window.

This function creates and adds a textbox to the specified window at the given position with a defined size. The textbox can display placeholder text, and a callback function is triggered whenever the text inside the textbox changes.

Parameters
xThe x-coordinate of the textbox's position.
yThe y-coordinate of the textbox's position.
widthThe width of the textbox.
heightThe height of the textbox.
placeholderThe placeholder text for the textbox.
onTextChangedThe callback function to call when the text changes.
Returns
A new GooeyTextbox object.

◆ GooeyTextbox_Draw()

void GooeyTextbox_Draw ( GooeyWindow *  win)

Draws the textbox on the window.

This function renders the textbox on the specified window. It should be called after the textbox's state has been updated to reflect the changes visually.

Parameters
winThe window to draw the textbox on.

◆ GooeyTextbox_GetText()

const char * GooeyTextbox_GetText ( GooeyTextbox *  textbox)

Gets the text of the textbox.

This function retrieves the current content of the textbox.

Parameters
textboxThe textbox to retrieve text from.
Returns
The current text of the textbox.

◆ GooeyTextbox_HandleClick()

bool GooeyTextbox_HandleClick ( GooeyWindow *  win,
int  x,
int  y 
)

Handles textbox click events.

This function is responsible for detecting and processing click events on the textbox. If the textbox is clicked, it will enter an active state.

Parameters
winThe window containing the textbox.
xThe x-coordinate of the click event.
yThe y-coordinate of the click event.
Returns
True if the textbox was clicked, false otherwise.

◆ GooeyTextbox_HandleKeyPress()

void GooeyTextbox_HandleKeyPress ( GooeyWindow *  win,
void *  event 
)

Handles key press events for the textbox.

This function processes key events, allowing the user to type text inside the textbox. The textbox's content is updated in real-time as the user types.

Parameters
winThe window containing the textbox.
eventThe key event to handle.

◆ GooeyTextbox_SetText()

void GooeyTextbox_SetText ( GooeyTextbox *  textbox,
const char *  text 
)

Sets the text of the textbox.

This function sets the textbox's content to the specified text.

Parameters
textboxThe textbox to set the text for.
textThe new text to set in the textbox.