UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_textentry.cpp File Reference

This node allow to edit a cvar text with the keyboard. When we click on the node, we active the edition, we can validate it with the ''RETURN'' key, or abort it with ''ESCAPE'' key. A validation fire a scriptable callback event. We can custom the mouse behaviour when we click outside the node in edition mode. It can validate or abort the edition. More...

#include "../ui_main.h"
#include "../ui_nodes.h"
#include "../ui_font.h"
#include "../ui_parse.h"
#include "../ui_behaviour.h"
#include "../ui_input.h"
#include "../ui_render.h"
#include "../ui_sprite.h"
#include "../ui_lua.h"
#include "ui_node_textentry.h"
#include "ui_node_abstractnode.h"
#include "ui_node_panel.h"
#include "../../client.h"
#include "../../../shared/utf8.h"
#include "../../../common/scripts_lua.h"
#include <SDL.h>
Include dependency graph for ui_node_textentry.cpp:

Go to the source code of this file.

Macros

#define EXTRADATA_TYPE   textEntryExtraData_t
#define EXTRADATA(node)
#define MAX_CVAR_EDITING_LENGTH   256 /* MAXCMDLINE */

Functions

void UI_TextEntry_SetBackgroundByName (uiNode_t *node, const char *name)
 set background sprite
static void UI_TextEntryNodeValidateEdition (uiNode_t *node)
 callback from the keyboard
static void UI_TextEntryNodeAbortEdition (uiNode_t *node)
 callback from the keyboard
void UI_TextEntryNodeFocus (uiNode_t *node, const uiCallContext_t *context)
 force edition of a textentry node
void UI_TextEntryNodeUnFocus (uiNode_t *node, const uiCallContext_t *context)
 force exit the edit mode of a textentry node
static void UI_TextEntryNodeEdit (uiNode_t *node, unsigned int unicode)
 edit the current cvar with a char
void UI_RegisterTextEntryNode (uiBehaviour_t *behaviour)

Variables

static const char CURSOR_ON = '|'
static const char CURSOR_OFF = ' '
static const char HIDECHAR = '*'
static char cvarValueBackup [MAX_CVAR_EDITING_LENGTH]
static cvar_teditedCvar = nullptr
static bool isAborted = false

Detailed Description

This node allow to edit a cvar text with the keyboard. When we click on the node, we active the edition, we can validate it with the ''RETURN'' key, or abort it with ''ESCAPE'' key. A validation fire a scriptable callback event. We can custom the mouse behaviour when we click outside the node in edition mode. It can validate or abort the edition.

Todo

allow to edit text without any cvar

add a custom max size

Definition in file ui_node_textentry.cpp.

Macro Definition Documentation

◆ EXTRADATA

#define EXTRADATA ( node)
Value:
#define EXTRADATA_TYPE
#define UI_EXTRADATA(NODE, TYPE)
Definition ui_nodes.h:185

Definition at line 54 of file ui_node_textentry.cpp.

Referenced by UI_TextEntryNodeAbortEdition(), and UI_TextEntryNodeEdit().

◆ EXTRADATA_TYPE

#define EXTRADATA_TYPE   textEntryExtraData_t

Definition at line 53 of file ui_node_textentry.cpp.

◆ MAX_CVAR_EDITING_LENGTH

#define MAX_CVAR_EDITING_LENGTH   256 /* MAXCMDLINE */

Definition at line 61 of file ui_node_textentry.cpp.

Referenced by UI_TextEntryNodeEdit().

Function Documentation

◆ UI_RegisterTextEntryNode()

◆ UI_TextEntry_SetBackgroundByName()

void UI_TextEntry_SetBackgroundByName ( uiNode_t * node,
const char * name )

set background sprite

Definition at line 71 of file ui_node_textentry.cpp.

References name, UI_EXTRADATA, and UI_GetSpriteByName().

Referenced by uiTextEntryNode_t_set_background().

◆ UI_TextEntryNodeAbortEdition()

void UI_TextEntryNodeAbortEdition ( uiNode_t * node)
static

callback from the keyboard

Definition at line 97 of file ui_node_textentry.cpp.

References Cvar_ForceSet(), cvarValueBackup, editedCvar, EXTRADATA, and UI_ExecuteEventActions().

Referenced by uiTextEntryNode::onFocusLost().

◆ UI_TextEntryNodeEdit()

void UI_TextEntryNodeEdit ( uiNode_t * node,
unsigned int unicode )
static

◆ UI_TextEntryNodeFocus()

void UI_TextEntryNodeFocus ( uiNode_t * node,
const uiCallContext_t * context )

force edition of a textentry node

Note
the textentry must be on the active window

Definition at line 118 of file ui_node_textentry.cpp.

References UI_HasFocus(), and UI_RequestFocus().

Referenced by UI_RegisterTextEntryNode(), and uiTextEntryNode_t_focus().

◆ UI_TextEntryNodeUnFocus()

void UI_TextEntryNodeUnFocus ( uiNode_t * node,
const uiCallContext_t * context )

force exit the edit mode of a textentry node

Note
the textentry must be on the active window

Definition at line 130 of file ui_node_textentry.cpp.

References UI_HasFocus(), and UI_RemoveFocus().

Referenced by UI_RegisterTextEntryNode(), and uiTextEntryNode_t_unfocus().

◆ UI_TextEntryNodeValidateEdition()

void UI_TextEntryNodeValidateEdition ( uiNode_t * node)
static

Variable Documentation

◆ CURSOR_OFF

const char CURSOR_OFF = ' '
static

Use as the cursor when we edit the text - invisible

Definition at line 57 of file ui_node_textentry.cpp.

Referenced by uiTextEntryNode::draw().

◆ CURSOR_ON

const char CURSOR_ON = '|'
static

Use as the cursor when we edit the text - visible

Definition at line 56 of file ui_node_textentry.cpp.

Referenced by uiTextEntryNode::draw().

◆ cvarValueBackup

◆ editedCvar

◆ HIDECHAR

const char HIDECHAR = '*'
static

use as a mask for password

Definition at line 58 of file ui_node_textentry.cpp.

Referenced by uiTextEntryNode::draw().

◆ isAborted

bool isAborted = false
static