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_input.h"
#include "../ui_actions.h"
#include "../ui_render.h"
#include "ui_node_textentry.h"
#include "ui_node_abstractnode.h"
#include "ui_node_panel.h"
#include "../../client.h"
#include "../../../shared/utf8.h"
Go to the source code of this file.
Defines | |
#define | EXTRADATA_TYPE textEntryExtraData_t |
#define | EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE) |
#define | TILE_SIZE 64 |
#define | CORNER_SIZE 17 |
#define | MID_SIZE 1 |
#define | MARGE 3 |
#define | MAX_CVAR_EDITING_LENGTH 256 |
Functions | |
static void | UI_TextEntryNodeValidateEdition (uiNode_t *node) |
callback from the keyboard | |
static void | UI_TextEntryNodeAbortEdition (uiNode_t *node) |
callback from the keyboard | |
static void | UI_TextEntryNodeFocus (uiNode_t *node, const uiCallContext_t *context) |
force edition of a textentry node | |
static void | UI_TextEntryNodeClick (uiNode_t *node, int x, int y) |
Called when the user click with the right mouse button. | |
static void | UI_TextEntryFocusGained (uiNode_t *node) |
Called when the node got the focus. | |
static void | UI_TextEntryFocusLost (uiNode_t *node) |
Called when the node lost the focus. | |
static void | UI_TextEntryNodeEdit (uiNode_t *node, unsigned int key) |
edit the current cvar with a char | |
static qboolean | UI_TextEntryNodeKeyPressed (uiNode_t *node, unsigned int key, unsigned short unicode) |
Called when we press a key when the node got the focus. | |
static void | UI_TextEntryNodeDraw (uiNode_t *node) |
static void | UI_TextEntryNodeLoading (uiNode_t *node) |
Call before the script initialization of the node. | |
void | UI_RegisterTextEntryNode (uiBehaviour_t *behaviour) |
Variables | |
static const char | CURSOR = '|' |
static const char | HIDECHAR = '*' |
static char | cvarValueBackup [MAX_CVAR_EDITING_LENGTH] |
static cvar_t * | editedCvar = NULL |
static qboolean | isAborted = qfalse |
static const value_t | properties [] |
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.
allow to edit text without any cvar
add a custom max size
Definition in file ui_node_textentry.c.
#define CORNER_SIZE 17 |
Definition at line 50 of file ui_node_textentry.c.
#define EXTRADATA | ( | node | ) | UI_EXTRADATA(node, EXTRADATA_TYPE) |
Definition at line 47 of file ui_node_textentry.c.
#define EXTRADATA_TYPE textEntryExtraData_t |
Definition at line 46 of file ui_node_textentry.c.
#define MARGE 3 |
Definition at line 52 of file ui_node_textentry.c.
#define MAX_CVAR_EDITING_LENGTH 256 |
Definition at line 58 of file ui_node_textentry.c.
Referenced by UI_TextEntryNodeEdit().
#define MID_SIZE 1 |
Definition at line 51 of file ui_node_textentry.c.
#define TILE_SIZE 64 |
Definition at line 49 of file ui_node_textentry.c.
void UI_RegisterTextEntryNode | ( | uiBehaviour_t * | behaviour | ) |
Definition at line 346 of file ui_node_textentry.c.
References uiBehaviour_s::draw, EXTRADATA_TYPE, uiBehaviour_s::extraDataSize, uiBehaviour_s::focusGained, uiBehaviour_s::focusLost, uiBehaviour_s::keyPressed, uiBehaviour_s::leftClick, uiBehaviour_s::loading, uiBehaviour_s::name, uiBehaviour_s::properties, UI_TextEntryFocusGained(), UI_TextEntryFocusLost(), UI_TextEntryNodeClick(), UI_TextEntryNodeDraw(), UI_TextEntryNodeKeyPressed(), and UI_TextEntryNodeLoading().
static void UI_TextEntryFocusGained | ( | uiNode_t * | node | ) | [static] |
Called when the node got the focus.
Definition at line 137 of file ui_node_textentry.c.
References Cvar_Get(), cvarValueBackup, isAborted, Q_strncpyz(), qfalse, cvar_s::string, and uiNode_s::text.
Referenced by UI_RegisterTextEntryNode().
static void UI_TextEntryFocusLost | ( | uiNode_t * | node | ) | [static] |
Called when the node lost the focus.
Definition at line 150 of file ui_node_textentry.c.
References EXTRADATA, isAborted, UI_TextEntryNodeAbortEdition(), and UI_TextEntryNodeValidateEdition().
Referenced by UI_RegisterTextEntryNode().
static void UI_TextEntryNodeAbortEdition | ( | uiNode_t * | node | ) | [static] |
callback from the keyboard
Definition at line 83 of file ui_node_textentry.c.
References Cvar_ForceSet(), cvarValueBackup, EXTRADATA, cvar_s::name, and UI_ExecuteEventActions().
Referenced by UI_TextEntryFocusLost().
static void UI_TextEntryNodeClick | ( | uiNode_t * | node, | |
int | x, | |||
int | y | |||
) | [static] |
Called when the user click with the right mouse button.
Definition at line 115 of file ui_node_textentry.c.
References uiNode_s::disabled, uiNode_s::onClick, uiNode_s::text, UI_ExecuteEventActions(), UI_HasFocus(), and UI_RequestFocus().
Referenced by UI_RegisterTextEntryNode().
static void UI_TextEntryNodeDraw | ( | uiNode_t * | node | ) | [static] |
Definition at line 225 of file ui_node_textentry.c.
References CL_Milliseconds(), uiNode_s::color, CORNER_SIZE, CURSOR, uiNode_s::disabled, EXTRADATA, HIDECHAR, uiNode_s::image, LONGLINES_PRETTYCHOP, MARGE, MID_SIZE, uiNode_s::padding, pos, R_Color(), uiNode_s::selectedColor, uiNode_s::size, uiNode_s::state, uiNode_s::text, uiNode_s::textalign, TILE_SIZE, UI_DrawPanel(), UI_DrawStringInBox(), UI_GetFontFromNode(), UI_GetNodeAbsPos(), UI_GetReferenceString(), UI_HasFocus(), UTF8_strlen(), and va().
Referenced by UI_RegisterTextEntryNode().
static void UI_TextEntryNodeEdit | ( | uiNode_t * | node, | |
unsigned int | key | |||
) | [static] |
edit the current cvar with a char
Definition at line 167 of file ui_node_textentry.c.
References Cvar_ForceSet(), K_BACKSPACE, MAX_CVAR_EDITING_LENGTH, cvar_s::name, Q_strncpyz(), cvar_s::string, UTF8_delete_char(), UTF8_encoded_len(), and UTF8_insert_char().
Referenced by UI_TextEntryNodeKeyPressed().
static void UI_TextEntryNodeFocus | ( | uiNode_t * | node, | |
const uiCallContext_t * | context | |||
) | [static] |
force edition of a textentry node
Definition at line 104 of file ui_node_textentry.c.
References UI_HasFocus(), and UI_RequestFocus().
static qboolean UI_TextEntryNodeKeyPressed | ( | uiNode_t * | node, | |
unsigned int | key, | |||
unsigned short | unicode | |||
) | [static] |
Called when we press a key when the node got the focus.
Definition at line 196 of file ui_node_textentry.c.
References isAborted, K_BACKSPACE, K_ENTER, K_ESCAPE, K_KP_ENTER, qfalse, qtrue, UI_RemoveFocus(), UI_TextEntryNodeEdit(), and UI_TextEntryNodeValidateEdition().
Referenced by UI_RegisterTextEntryNode().
static void UI_TextEntryNodeLoading | ( | uiNode_t * | node | ) | [static] |
Call before the script initialization of the node.
Definition at line 307 of file ui_node_textentry.c.
References ALIGN_CL, uiNode_s::color, uiNode_s::padding, uiNode_s::selectedColor, uiNode_s::textalign, and Vector4Set.
Referenced by UI_RegisterTextEntryNode().
static void UI_TextEntryNodeValidateEdition | ( | uiNode_t * | node | ) | [static] |
callback from the keyboard
Definition at line 68 of file ui_node_textentry.c.
References cvarValueBackup, uiNode_s::onChange, and UI_ExecuteEventActions().
Referenced by UI_TextEntryFocusLost(), and UI_TextEntryNodeKeyPressed().
const char CURSOR = '|' [static] |
Use as the cursor when we edit the text
Definition at line 54 of file ui_node_textentry.c.
Referenced by UI_TextEntryNodeDraw().
char cvarValueBackup[MAX_CVAR_EDITING_LENGTH] [static] |
Definition at line 61 of file ui_node_textentry.c.
Referenced by UI_TextEntryFocusGained(), UI_TextEntryNodeAbortEdition(), and UI_TextEntryNodeValidateEdition().
cvar_t* editedCvar = NULL [static] |
Definition at line 62 of file ui_node_textentry.c.
const char HIDECHAR = '*' [static] |
use as a mask for password
Definition at line 55 of file ui_node_textentry.c.
Referenced by UI_TextEntryNodeDraw().
Definition at line 63 of file ui_node_textentry.c.
Referenced by UI_TextEntryFocusGained(), UI_TextEntryFocusLost(), and UI_TextEntryNodeKeyPressed().
const value_t properties[] [static] |
{ {"ispassword", V_BOOL, UI_EXTRADATA_OFFSETOF(textEntryExtraData_t, isPassword), MEMBER_SIZEOF(textEntryExtraData_t, isPassword)}, {"clickoutabort", V_BOOL, UI_EXTRADATA_OFFSETOF(textEntryExtraData_t, clickOutAbort), MEMBER_SIZEOF(textEntryExtraData_t, clickOutAbort)}, {"onabort", V_UI_ACTION, UI_EXTRADATA_OFFSETOF(textEntryExtraData_t, onAbort), MEMBER_SIZEOF(textEntryExtraData_t, onAbort)}, {"edit", V_UI_NODEMETHOD, ((size_t) UI_TextEntryNodeFocus), 0}, {NULL, V_NULL, 0, 0} }
Definition at line 315 of file ui_node_textentry.c.