From 96bdfac9cc6e7605180d2e3793bf19ca0abd28f0 Mon Sep 17 00:00:00 2001 From: "M. Ian Graham" Date: Thu, 14 Jun 2007 00:51:12 +0000 Subject: [PATCH] setAcceptEnabled added to allow us to disable submission of input --- panda/src/pgui/pgEntry.I | 11 +++++++++++ panda/src/pgui/pgEntry.cxx | 6 +++++- panda/src/pgui/pgEntry.h | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index d4c8135f5c..34655b3125 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -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; +} diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index 277db9dc41..849fdbfefb 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -207,7 +207,9 @@ press(const MouseWatcherParameter ¶m, 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(); diff --git a/panda/src/pgui/pgEntry.h b/panda/src/pgui/pgEntry.h index 7179ebb2b4..e856ae13ba 100644 --- a/panda/src/pgui/pgEntry.h +++ b/panda/src/pgui/pgEntry.h @@ -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;