setAcceptEnabled added to allow us to disable submission of input

This commit is contained in:
M. Ian Graham 2007-06-14 00:51:12 +00:00
parent 38dfa82743
commit 96bdfac9cc
3 changed files with 19 additions and 1 deletions

View File

@ -448,3 +448,14 @@ INLINE const wstring &PGEntry::
get_wtext() const {
return _wtext;
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::set_accept_enabled
// Access: Published
// Description: Sets whether the input may be accepted--use to
// disable submission by the user
////////////////////////////////////////////////////////////////////
INLINE void PGEntry::
set_accept_enabled(bool enabled) {
_accept_enabled = enabled;
}

View File

@ -207,7 +207,9 @@ press(const MouseWatcherParameter &param, bool background) {
_blink_start = ClockObject::get_global_clock()->get_frame_time();
if (button == KeyboardButton::enter()) {
// Enter. Accept the entry.
accept(param);
if (_accept_enabled) {
accept(param);
}
} else if (button == KeyboardButton::backspace()) {
// Backspace. Remove the character to the left of the cursor.
@ -526,6 +528,8 @@ setup(float width, int num_lines) {
set_max_width(width);
set_num_lines(num_lines);
_accept_enabled = true;
TextNode *text_node = get_text_def(S_focus);
float line_height = text_node->get_line_height();

View File

@ -122,6 +122,7 @@ PUBLISHED:
INLINE void set_wtext(const wstring &wtext);
INLINE const wstring &get_wtext() const;
INLINE void set_accept_enabled(bool enabled);
bool is_wtext() const;
@ -148,6 +149,8 @@ private:
float _max_width;
int _num_lines;
bool _accept_enabled;
string _candidate_active;
string _candidate_inactive;