Selaa lähdekoodia

setAcceptEnabled added to allow us to disable submission of input

M. Ian Graham 18 vuotta sitten
vanhempi
sitoutus
96bdfac9cc
3 muutettua tiedostoa jossa 19 lisäystä ja 1 poistoa
  1. 11 0
      panda/src/pgui/pgEntry.I
  2. 5 1
      panda/src/pgui/pgEntry.cxx
  3. 3 0
      panda/src/pgui/pgEntry.h

+ 11 - 0
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;
+}

+ 5 - 1
panda/src/pgui/pgEntry.cxx

@@ -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();
 

+ 3 - 0
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;