UFO: Alien Invasion
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 dependency graph for ui_node_textentry.cpp:

Go to the source code of this file.

Macros

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

Functions

void UI_TextEntry_SetBackgroundByName (uiNode_t *node, const char *name)
 set background sprite More...
 
static void UI_TextEntryNodeValidateEdition (uiNode_t *node)
 callback from the keyboard More...
 
static void UI_TextEntryNodeAbortEdition (uiNode_t *node)
 callback from the keyboard More...
 
void UI_TextEntryNodeFocus (uiNode_t *node, const uiCallContext_t *context)
 force edition of a textentry node More...
 
void UI_TextEntryNodeUnFocus (uiNode_t *node, const uiCallContext_t *context)
 force exit the edit mode of a textentry node More...
 
static void UI_TextEntryNodeEdit (uiNode_t *node, unsigned int unicode)
 edit the current cvar with a char More...
 
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)    UI_EXTRADATA(node, EXTRADATA_TYPE)

Definition at line 60 of file ui_node_textentry.cpp.

◆ EXTRADATA_TYPE

#define EXTRADATA_TYPE   textEntryExtraData_t

Definition at line 59 of file ui_node_textentry.cpp.

◆ MAX_CVAR_EDITING_LENGTH

#define MAX_CVAR_EDITING_LENGTH   256 /* MAXCMDLINE */

Definition at line 67 of file ui_node_textentry.cpp.

Function Documentation

◆ UI_RegisterTextEntryNode()

◆ UI_TextEntry_SetBackgroundByName()

void UI_TextEntry_SetBackgroundByName ( uiNode_t node,
const char *  name 
)

set background sprite

Definition at line 77 of file ui_node_textentry.cpp.

References name, UI_EXTRADATA, and UI_GetSpriteByName().

Referenced by uiTextEntryNode_t_set_background().

◆ UI_TextEntryNodeAbortEdition()

static void UI_TextEntryNodeAbortEdition ( uiNode_t node)
static

callback from the keyboard

Definition at line 103 of file ui_node_textentry.cpp.

References Cvar_ForceSet(), cvarValueBackup, editedCvar, EXTRADATA, cvar_t::name, and UI_ExecuteEventActions().

Referenced by uiTextEntryNode::onFocusLost().

◆ UI_TextEntryNodeEdit()

static 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 124 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 136 of file ui_node_textentry.cpp.

References UI_HasFocus(), and UI_RemoveFocus().

Referenced by UI_RegisterTextEntryNode(), and uiTextEntryNode_t_unfocus().

◆ UI_TextEntryNodeValidateEdition()

static 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 63 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 62 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 64 of file ui_node_textentry.cpp.

Referenced by uiTextEntryNode::draw().

◆ isAborted

bool isAborted = false
static