Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 |
// ==================================================================== // Class: XInterface.GUIEditBox // // GUIEditBox - The basic text edit control. I've merged Normal // edit, restricted edit, numeric edit and password edit in to 1 control. // // Written by Joe Wilcox // Updated by Ron Prestenback // (c) 2002, 2003, Epic Games, Inc. All Rights Reserved // ==================================================================== class GUIEditBox extends GUIButton Native; #exec OBJ LOAD FILE=InterfaceContent.utx // (cpptext) // (cpptext) // (cpptext) // (cpptext) var() string TextStr; // Holds the current string var() string AllowedCharSet; // Only Allow these characters var() bool bMaskText; // Displays the text as a * var() bool bIntOnly; // Only Allow Interger Numeric entry var() bool bFloatOnly; // Only Allow Float Numeric entry var() bool bIncludeSign; // Do we need to allow a -/+ sign var() bool bConvertSpaces; // Do we want to convert Spaces to "_" var() int MaxWidth; // Holds the maximum width (in chars) of the string - 0 = No Max var() eTextCase TextCase; // Controls forcing case, etc var() int BorderOffsets[4]; // How far in from the edit is the edit area var() bool bReadOnly; // Can't actually edit this box var() bool bAlwaysNotify; // If true, send OnChange event when receive SetText(), even if text is identical var int CaretPos; // Where is the cursor within the string var int FirstVis; // Position of the first visible character; var int LastSizeX; // Used to detect resolution changes var int LastCaret,LastLength; // Used to make things quick var bool bAllSelected; var byte LastKey; var() float DelayTime; function InitComponent(GUIController MyController, GUIComponent MyOwner) { Super.InitComponent(MyController, MyOwner); if ( bIntOnly || bFloatOnly ) { AllowedCharSet = "0123456789"; if (bFloatOnly) AllowedCharSet $= "."; } bAllSelected=true; } event SetText(string NewText) { local bool bChanged; bChanged = bAlwaysNotify || TextStr != NewText; TextStr = NewText; CaretPos=len(TextStr); if (bChanged) TextChanged(); bAllSelected=true; } function DeleteChar() { if (CaretPos==len(TextStr)) return; else if (CaretPos==Len(TextStr)-1) { TextStr = left(TextStr,CaretPos); CaretPos=len(TextStr); } else TextStr = left(TextStr,CaretPos)$Mid(TextStr,CaretPos+1); TextChanged(); } function bool InternalOnKeyType(out byte Key, optional string Unicode) { local string temp,st; if (bReadOnly) return false; if (UniCode!="") st = Unicode; else st = chr(Key); // Handle cut/paste/copy keys if (key<32) { if (!Controller.CtrlPressed || key == 9) return false; // old code captured any keys under 32 switch (key) { case 3: // ctrl-c, copy to console PlayerOwner().CopyToClipboard(TextStr); bAllSelected=true; break; case 22: // ctrl-v, paste at position if ( (TextStr=="") || ( CaretPos==len(TextStr) ) ) // At the end of the string, just add { if (bAllSelected) TextStr=""; TextStr = ConvertIllegal(TextStr$PlayerOwner().PasteFromClipboard()); CaretPos=len(TextStr); } else { // We are somewhere inside the string, insert. temp = ConvertIllegal(left(TextStr,CaretPos)$PlayerOwner().PasteFromClipboard()$Mid(TextStr,CaretPos)); TextStr = temp; } break; case 24: // ctrl-x, clear and copy PlayerOwner().CopyToClipboard(TextStr); TextStr=""; CaretPos=0; } TextChanged(); return true; } if(bAllSelected) { TextStr=""; CaretPos=0; bAllSelected=false; } if ( (AllowedCharSet=="") || ( (bIncludeSign) && ( (st=="-") || (st=="+") ) && (TextStr=="") ) || (InStr(AllowedCharSet,St)>=0) ) { if ( (MaxWidth==0) || (Len(TextStr)<MaxWidth) ) { if ( (bConvertSpaces) && ((st==" ") || (st=="?") || (st=="\\")) ) st = "_"; if ( (TextStr=="") || ( CaretPos==len(TextStr) ) ) // At the end of the string, just add { TextStr = TextStr$st; CaretPos=len(TextStr); } else { // We are somewhere inside the string, insert it. temp = left(TextStr,CaretPos)$st$Mid(TextStr,CaretPos); TextStr = temp; CaretPos++; } TextChanged(); return true; } } return false; } function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) { if (bReadOnly || State != 1) return false; if( Key==8 ) // Process Backspace { if (CaretPos>0) { if ( bAllSelected ) { TextStr = ""; CaretPos = 0; bAllSelected = False; TextChanged(); } else { CaretPos--; DeleteChar(); } } return true; } if ( Key==0x2E ) // Delete key { if(bAllSelected) { TextStr=""; CaretPos = 0; bAllSelected=false; TextChanged(); } else DeleteChar(); return true; } //if ( (Key==0x64 || Key==0x25) && (State==1) ) // Left Arrow if ( Key==0x25 ) // Left Arrow { if(bAllSelected) { CaretPos = 0; bAllSelected=false; } else if (CaretPos>0) CaretPos--; return true; } //if ( (Key==0x66 || Key==0x27) && (State==1) ) // Right Arrow if (Key==0x27) // Right Arrow { if(bAllSelected) { CaretPos = len(TextStr); bAllSelected=false; } else if ( CaretPos<Len(TextStr) ) CaretPos++; return true; } //if ( (Key==0x24 || Key==0x67) && (State==1) ) // Home if (Key==0x24) // Home { CaretPos=0; bAllSelected=false; return true; } //if ( (Key==0x23 || Key==0x61) && (State==1) ) // End if (Key==0x23) // End { CaretPos=len(TextStr); bAllSelected=false; return true; } if ( Key == 0x41 && Controller.CtrlPressed ) { bAllSelected=true; return true; } return false; } // converts space-characters and chars not in the allowed char array // ensure string stays within max bounds function string ConvertIllegal(string inputstr) { local int i, max; local string retval; local string c; i = 0; max = Len(inputstr); while ( i < max ) { c = Mid(inputstr,i,1); if ( AllowedCharSet != "" && InStr(AllowedCharSet,c) < 0 ) { c = ""; } if ( bConvertSpaces && ((c == " ") || (c =="?") || (c=="\\") )) { c = "_"; } retval = retval $ c; i++; } if (MaxWidth > 0) return Left(retval,MaxWidth); return retval; } function string GetText() { return TextStr; } function TextChanged() { OnChange(Self); } function InternalActivate() { CaretPos = Len(TextStr); bAllSelected = True; } function InternalDeactivate() { CaretPos = 0; bAllSelected = False; } defaultproperties { MaxWidth=768 LastCaret=-1 LastLength=-1 StyleName="EditBox" WinHeight=0.060000 bCaptureMouse=False bRequiresStyle=True OnClickSound=CS_Edit OnActivate=GUIEditBox.InternalActivate OnDeActivate=GUIEditBox.InternalDeactivate OnKeyType=GUIEditBox.InternalOnKeyType OnKeyEvent=GUIEditBox.InternalOnKeyEvent } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |