netpanzer-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netPanzer-CVS] netpanzer/src/NetPanzer/View cInputField.cpp cI...


From: Hankin Chick
Subject: [netPanzer-CVS] netpanzer/src/NetPanzer/View cInputField.cpp cI...
Date: Sun, 23 Nov 2003 19:59:12 -0500

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Hankin Chick <address@hidden>   03/11/23 19:59:11

Modified files:
        src/NetPanzer/View: cInputField.cpp cInputField.hpp 

Log message:
        insert back repeats
        small fix for end key

Patches:
Index: netpanzer/src/NetPanzer/View/cInputField.cpp
diff -u netpanzer/src/NetPanzer/View/cInputField.cpp:1.1 
netpanzer/src/NetPanzer/View/cInputField.cpp:1.2
--- netpanzer/src/NetPanzer/View/cInputField.cpp:1.1    Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/cInputField.cpp        Sun Nov 23 19:59:11 2003
@@ -207,7 +207,7 @@
     case SDLK_END: {
             cursorPos = strlen(destString);
 
-            if (cursorPos > maxCharCount) {
+            if (cursorPos >= maxCharCount) {
                 cursorPos = maxCharCount - 1;
             }
         }
@@ -259,6 +259,7 @@
 void cInputField::draw(Surface &dest)
 {
     checkCursor();
+    checkRepeat();
 
     inputFieldSurface.fill(Color::black);
     inputFieldSurface.drawButtonBorder(Color::white, Color::gray64);
@@ -271,6 +272,7 @@
 void cInputField::drawHighlighted(Surface &dest)
 {
     checkCursor();
+    checkRepeat();
 
     inputFieldSurface.fill(Color::black);
     inputFieldSurface.drawButtonBorder(Color::darkGray, Color::white);
@@ -317,5 +319,27 @@
 {
     depressedKey=ch;
     depressedKeyTimeNext=SDL_GetTicks()+250;
+}
+
+// check repeat and insert characters as needed
+void cInputField::checkRepeat()
+{
+    if(depressedKey==0) { return; }
+    Uint32 ticks=SDL_GetTicks();
+    if(depressedKeyTimeNext>ticks) {
+        return;
+    }
+    if(KeyboardInterface::getKeyState(depressedKey)!=true) {
+        // we've let go of this key.
+        depressedKey=0;
+        return;
+    }
+
+    if(isprint(depressedKey)) {
+        addChar(depressedKey);
+    }
+    else { addExtendedChar(depressedKey); }
+
+    depressedKeyTimeNext=ticks+50;
 }
 
Index: netpanzer/src/NetPanzer/View/cInputField.hpp
diff -u netpanzer/src/NetPanzer/View/cInputField.hpp:1.1 
netpanzer/src/NetPanzer/View/cInputField.hpp:1.2
--- netpanzer/src/NetPanzer/View/cInputField.hpp:1.1    Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/cInputField.hpp        Sun Nov 23 19:59:11 2003
@@ -132,6 +132,7 @@
     ACTION_FUNC_PTR returnaction;
 
     void pressKey(int ch);
+    void checkRepeat();
     void reset();
 }; // end cInputField
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]