ui_node_textentry.c 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_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"
Include dependency graph for ui_node_textentry.c:

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_teditedCvar = NULL
static qboolean isAborted = qfalse
static const value_t properties []

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.c.


Define Documentation

#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.


Function Documentation

void UI_RegisterTextEntryNode ( uiBehaviour_t behaviour  ) 
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]
static void UI_TextEntryNodeEdit ( uiNode_t node,
unsigned int  key 
) [static]
static void UI_TextEntryNodeFocus ( uiNode_t node,
const uiCallContext_t context 
) [static]

force edition of a textentry node

Note:
the textentry must be on the active window

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.

Returns:
True, if we use the event

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().


Variable Documentation

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]
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().

qboolean isAborted = qfalse [static]
const value_t properties[] [static]
Initial value:
 {
    
    
    

    
    {"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.


Generated by  doxygen 1.6.2