# PGEntry¶

class PGEntry

Bases: PGItem

This is a particular kind of PGItem that handles simple one-line or short multi-line text entries, of the sort where the user can type any string.

A PGEntry does all of its internal manipulation on a wide string, so it can store the full Unicode character set. The interface can support either the wide string getters and setters, or the normal 8-bit string getters and setters, which use whatever encoding method is specified by the associated TextNode.

Inheritance diagram

enum State
enumerator S_focus = 0
enumerator S_no_focus = 1
enumerator S_inactive = 2
explicit PGEntry(std::string const &name)
void clear_cursor_def(void)

Removes all the children from the cursor_def node, in preparation for adding a new definition.

std::string get_accept_event(ButtonHandle const &button) const

Returns the event name that will be thrown when the entry is accepted normally.

std::string get_accept_failed_event(ButtonHandle const &button) const

Returns the event name that will be thrown when the entry cannot accept an input

std::string get_accept_failed_prefix(void)

Returns the prefix that is used to define the accept failed event for all PGEntries. This event is the concatenation of this string followed by get_id().

std::string get_accept_prefix(void)

Returns the prefix that is used to define the accept event for all PGEntries. The accept event is the concatenation of this string followed by get_id().

Returns the number of times per second the cursor will blink, or 0 if the cursor is not to blink.

std::string const &get_candidate_active(void) const
std::string const &get_candidate_inactive(void) const
wchar_t get_character(int n) const

Returns the character at the indicated position in the entry. If the object at this position is a graphic object instead of a character, returns 0.

static TypeHandle get_class_type(void)
PN_stdfloat get_cursor_X(void) const
PN_stdfloat get_cursor_Y(void) const
NodePath get_cursor_def(void)

Returns the Node that will be rendered to represent the cursor. You can attach suitable cursor geometry to this node.

bool get_cursor_keys_active(void) const

Returns whether the arrow keys are currently set to control movement of the cursor; see set_cursor_keys_active().

int get_cursor_position(void) const

Returns the current position of the cursor.

std::string get_cursormove_event(void) const

Returns the event name that will be thrown whenever the cursor moves

std::string get_cursormove_prefix(void)

Returns the prefix that is used to define the cursor event for all PGEntries. The cursor event is the concatenation of this string followed by get_id().

std::string get_erase_event(void) const

Returns the event name that will be thrown whenever the user erases characters in the text.

std::string get_erase_prefix(void)

Returns the prefix that is used to define the erase event for all PGEntries. The erase event is the concatenation of this string followed by get_id().

TextGraphic const *get_graphic(int n) const

Returns the graphic object at the indicated position in the pre-wordwrapped string. If the object at this position is a character instead of a graphic object, returns NULL.

int get_max_chars(void) const

Returns the current maximum number of characters that may be typed into the entry, or 0 if there is no limit. See set_max_chars().

PN_stdfloat get_max_width(void) const

Returns the current maximum width of the characters that may be typed into the entry, or 0 if there is no limit. See set_max_width().

int get_num_characters(void) const

Returns the number of characters of text in the entry. This is the actual number of visible characters, not counting implicit newlines due to wordwrapping, or formatted characters for text properties changes. If there is an embedded TextGraphic object, it counts as one character.

This is also the length of the string returned by get_plain_text().

int get_num_lines(void) const

Returns the number of lines of text the PGEntry will use, if _max_width is not 0. See set_num_lines().

bool get_obscure_mode(void) const

Specifies whether obscure mode is enabled. See set_obscure_mode().

std::string get_overflow_event(void) const

Returns the event name that will be thrown when too much text is attempted to be entered into the PGEntry, exceeding either the limit set via set_max_chars() or via set_max_width().

bool get_overflow_mode(void) const

Specifies whether overflow mode is enabled. See set_overflow_mode().

std::string get_overflow_prefix(void)

Returns the prefix that is used to define the overflow event for all PGEntries. The overflow event is the concatenation of this string followed by get_id().

std::string get_plain_text(void) const

Returns the text currently displayed within the entry, without any embedded properties characters.

This uses the Unicode encoding currently specified for the “focus” TextNode; therefore, the TextNode must exist before calling get_text().

std::wstring get_plain_wtext(void) const

Returns the text currently displayed within the entry, without any embedded properties characters.

TextProperties const &get_properties(int n) const

Returns the TextProperties in effect for the object at the indicated position in the pre-wordwrapped string.

std::string get_text(void) const

Returns the text currently displayed within the entry. This uses the Unicode encoding currently specified for the “focus” TextNode; therefore, the TextNode must exist before calling get_text().

TextNode *get_text_def(int state) const

Returns the TextNode that will be used to render the text within the entry when the entry is in the indicated state. See set_text_def().

std::string get_type_event(void) const

Returns the event name that will be thrown whenever the user extends the text by typing.

std::string get_type_prefix(void)

Returns the prefix that is used to define the type event for all PGEntries. The type event is the concatenation of this string followed by get_id().

std::wstring get_wtext(void) const

Returns the text currently displayed within the entry.

bool is_wtext(void) const

Returns true if any of the characters in the string returned by get_wtext() are out of the range of an ASCII character (and, therefore, get_wtext() should be called in preference to get_text()).

void set_accept_enabled(bool enabled)

Sets whether the input may be accepted–use to disable submission by the user

Sets the number of times per second the cursor will blink while the entry has keyboard focus.

If this is 0, the cursor does not blink, but is held steady.

void set_candidate_active(std::string const &candidate_active)

Specifies the name of the TextProperties structure added to the TextPropertiesManager that will be used to render candidate strings from the IME, used for typing characters in east Asian languages. Each candidate string represents one possible way to interpret the sequence of keys the user has just entered; it should not be considered typed yet, but it is important for the user to be able to see what he is considering entering.

This particular method sets the properties for the subset of the current candidate string that the user can actively scroll through.

void set_candidate_inactive(std::string const &candidate_inactive)

Specifies the name of the TextProperties structure added to the TextPropertiesManager that will be used to render candidate strings from the IME, used for typing characters in east Asian languages. Each candidate string represents one possible way to interpret the sequence of keys the user has just entered; it should not be considered typed yet, but it is important for the user to be able to see what he is considering entering.

This particular method sets the properties for the subset of the current candidate string that the user is not actively scrolling through.

void set_cursor_keys_active(bool flag)

Sets whether the arrow keys (and home/end) control movement of the cursor. If true, they are active; if false, they are ignored.

void set_cursor_position(int position)

Sets the current position of the cursor. This is the position within the text at which the next letter typed by the user will be inserted; normally it is the same as the length of the text.

void set_max_chars(int max_chars)

Sets the maximum number of characters that may be typed into the entry. This is a limit on the number of characters, as opposed to the width of the entry; see also set_max_width().

If this is 0, there is no limit.

void set_max_width(PN_stdfloat max_width)

Sets the maximum width of all characters that may be typed into the entry. This is a limit on the width of the formatted text, not a fixed limit on the number of characters; also set_max_chars().

If this is 0, there is no limit.

If _num_lines is more than 1, rather than being a fixed width on the whole entry, this becomes instead the wordwrap width (and the width limit on the entry is essentially _max_width * _num_lines).

void set_num_lines(int num_lines)

Sets the number of lines of text the PGEntry will use. This only has meaning if _max_width is not 0; _max_width indicates the wordwrap width of each line.

void set_obscure_mode(bool flag)

Specifies whether obscure mode should be enabled. In obscure mode, a string of asterisks is displayed instead of the literal text, e.g. for entering passwords.

In obscure mode, the width of the text is computed based on the width of the string of asterisks, not on the width of the actual text. This has implications on the maximum length of text that may be entered if max_width is in effect.

void set_overflow_mode(bool flag)

Specifies whether overflow mode should be enabled. In overflow mode, text can overflow the boundaries of the Entry element horizontally.

Overflow mode only works when the number of lines is 1.

bool set_text(std::string const &text)

Changes the text currently displayed within the entry. This uses the Unicode encoding currently specified for the “focus” TextNode; therefore, the TextNode must exist before calling set_text().

The return value is true if all the text is accepted, or false if some was truncated (see set_max_width(), etc.).

void set_text_def(int state, TextNode *node)

Changes the TextNode that will be used to render the text within the entry when the entry is in the indicated state. The default if nothing is specified is the same TextNode returned by PGItem::get_text_node().

bool set_wtext(std::wstring const &wtext)

Changes the text currently displayed within the entry.

The return value is true if all the text is accepted, or false if some was truncated (see set_max_width(), etc.).

void setup(PN_stdfloat width, int num_lines)

Sets up the entry for normal use. The width is the maximum width of characters that will be typed, and num_lines is the integer number of lines of text of the entry. Both of these together determine the size of the entry, based on the TextNode in effect.

void setup_minimal(PN_stdfloat width, int num_lines)

Sets up the entry without creating any frame or other decoration.