#include "Content\\ShellScripts\\ScriptStrings.h" #include "Content\\ShellScripts\\stddefs.h" //=================================================================================== //Object: s_editbox // //Description: a simple editbox // //Member Variables: // // Name: p_pane // Type: pane // Description: the texture you wish to draw, assumes 0,0 as top left corner. To move change location // // Name: backColor // Type: int (color) // Description: the color that will be drawn beneath the pane (will show if pane has alpha) // // Name: id // Type: int // Description: unique integer used so function handler objects know who is sending mail // //Initialization: // //Notes: // //TODO: upgrade this object to use the new textBox object // update this comment box to match the new format // need no species of edit box for the IP address and phone number // allow the double click select and clear like windows // support paste? // trap all garbage chars not just tab or error // //=================================================================================== s_editbox { GUI_CREATE { //Member Variables string boxValue = "" //CAN BE INITIALIZED holds the contents of the edit box string backup = "" int boxWidth = 0 //MUST BE INTIALIZED width of the edit field of the box int boxHeight = 0 //MUST BE INTIALIZED height of the edit field of the box// int boxtextlimit = 255 //CAN BE INTIALIZED font3d boxFont3d = FPATH localize$(IDS_F_GEN_EDITBOX) //MUST BE INITIALIZED position boxTextOffset = 0,0 //CAN BE INITIALIZED int backColor = packcolor ( 0, 0, 0, 255) //CAN BE INITIALIZED int borderColor = packcolor (255, 255, 255, 255) //CAN BE INITIALIZED int boxTextColor = packcolor (255, 255, 255, 255) //CAN BE INITIALIZED int labelTextColor = packcolor (255, 255, 255, 255) //CAN BE INITIALIZED int selectedColor = packcolor (255, 255, 255, 255) //CAN BE INITIALIZED int highlightedColor = packcolor (50, 125, 255, 255) //CAN BE INITIALIZED int facecolor = packcolor (187, 187, 204, 255) int shadowcolor = packcolor (119, 119, 119, 255) int noEditColor = packcolor (255,255,255,128) int blink = 0 //FOR CURSOR BLINK (ON/OFF) int cursor_pos //LOC TO DRAW CURSOR int letter_start_pos //REMEMBERS WHERE YOU STARTED TO HIGHLIGHT TEXT int letter_pos //CURRENT LETTER BEING POINTED TO int highlight_start_pos //REMEMBERS THE LOC (IN PIXELS) YOU STARTED TO HIGHLIGHT TEXT int highlight_pos //CURRENT LOC OF HIGHLIGHT BAR int find_pos //USED TO FIND DIFFERENT POS int highlight //TRUE/FALSE int displayed_start //POINTS TO FIRST LETTER TO PRINT IN BOX int displayed_end //POINTS TO LAST LETTER TO PRINT IN BOX string displayed_text //STRING THAT STORES WHAT THE USER SEES string temp //used to temporarily slice and dice text before handing off the result to boxValue and displayed_tect int cliplength string clip int PasswordBox = FALSE int NumericOnly = FALSE int keyboard_sound = FALSE int Auto_Update = TRUE string s_pword = "" int scroll_x_value = 0 int find_first int active = false int over_me = false int disable_forward_slash = false int bl_noEdit = 0 int inserttext = true int blink_count int font_height string label = "" //CAN BE INITIALIZED font3d labelFont3d = FPATH localize$(IDS_F_GEN_EDITBOX) position offset //CAN BE INITIALIZED offset of text from button int TimeLimit = -2 int id = 0 sound typing sound message //Gosscript Variables region = 0,0 to 0,0 //MUST BE INTIALIZED region should be set manually after the boxwidth and height are set catchup = false location= 0,0,0 //CAN BE INITIALIZED framerate = 30 } GUI_INIT { if keyboard_sound == TRUE { typing = SPATH "fx_button.wav" message = SPATH "sfx_signal_inmessage.wav" assign 2, typing assign 3, message setvolume (2, 100) setvolume (3, 20) } region = 0,0 to boxWidth,boxHeight print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 font_height = getprint3dheight("Temp") displayed_start = 0 letter_pos = length$(boxvalue) + 1 if(PasswordBox == TRUE) { s_pword = 0 for(int i=0; i < length$(boxvalue); i++) s_pword = s_pword "*" } //Makes the display correct for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) callback($$ImeCallback$$, 1, inserttext) // notify GOS with insert mode. } REGION_ENTERED { over_me = true if exists(@infobox@) { mail(id, @infobox@) } } REGION_EXITED { over_me = false if exists(@infobox@) { mail(-1, @infobox@) } } GUI_FOCUS { print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 active = true highlight = true highlight_start_pos = 0 letter_start_pos = 1 letter_pos = length$(boxvalue)+1 //Makes the display correct for find_first = letter_pos-1; find_first > -1; find_first-- { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,find_first,letter_pos-1)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,find_first,letter_pos-1)) > boxWidth-8 { break } } } displayed_start = find_first+1 displayed_end = letter_pos-1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) highlight_pos = cursor_pos } GUI_UNFOCUS { active = false highlight = false displayed_start = 0 //Makes the display correct print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 if Auto_Update == TRUE mail(2) } GUI_CHAR { print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 if ((getchar() == char("\n")) || (getchar() == 9)) //9 is the value of a tab { if keyboard_sound == TRUE play 3 highlight = false mail(1) if (getchar() == 9) { mail(M_TABEVENT, parent) } return } int key = getCTRLchar() if KEY == 45 //Insert { if (getkeystate(key_lcontrol)) { if letter_start_pos > letter_pos setclipboard(mid$(boxValue,letter_pos-1,letter_start_pos-1)) else setclipboard(mid$(boxValue,letter_start_pos-1,letter_pos-1)) } else if (getkeystate(key_lshift)) { getclipboard(clip,boxTextLimit) cliplength = length$(clip) if highlight { if length$(boxValue)+cliplength-(abs(letter_start_pos-letter_pos)) <= boxTextLimit { highlight = false if letter_start_pos < letter_pos { temp = left$(boxValue,letter_start_pos-1) clip right$(boxValue,length$(boxValue)-(letter_pos-1)) letter_pos = letter_start_pos } else { temp = left$(boxValue,letter_pos-1) clip right$(boxValue,length$(boxValue)-(letter_start_pos-1)) } letter_pos += cliplength if (length$(temp) < 1) { boxValue = clip letter_pos = 1 displayed_start = 0 displayed_end = 1 } } } else { if length$(boxValue)+cliplength <= boxTextLimit { temp = left$(boxValue,letter_pos-1) clip right$(boxValue,length$(boxValue)-(letter_pos-1)) letter_pos += cliplength } } boxValue = temp if letter_pos > displayed_end+1 //letter_pos > displayed_end && { //Makes the display correct for find_first = letter_pos-2; find_first > -1; find_first-- { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,find_first,letter_pos-1)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,find_first,letter_pos-1)) > boxWidth-8 { break } } } displayed_start = find_first+1 displayed_end = letter_pos-1 } else { //Makes the display correct for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 } // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if highlight == false { letter_start_pos = letter_pos highlight_start_pos = cursor_pos highlight_pos = highlight_start_pos } // mail(CC_EDT_CHANGED,parent) } else { inserttext = !inserttext callback($$ImeCallback$$, 1, inserttext) // notify GOS with insert mode. } } else if KEY == 36 //HOME { if (getkeystate(key_lshift)) { displayed_start = 0 highlight = true letter_pos = 1 //Makes the display correct for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos } else { displayed_start = 0 letter_pos = 1 letter_start_pos = letter_pos //Makes the display correct for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_start_pos = cursor_pos highlight_pos = cursor_pos } if highlight { if letter_start_pos-1 < displayed_start { highlight_start_pos = 0 } else { if letter_start_pos > displayed_end highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_start_pos-1)) } } } else if KEY == 35 // END { if (getkeystate(key_lshift)) { highlight = true letter_pos = length$(boxvalue)+1 } else { letter_pos = length$(boxvalue)+1 letter_start_pos = letter_pos highlight_start_pos = cursor_pos } //Makes the display correct for find_first = letter_pos-1; find_first > -1; find_first-- { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,find_first,letter_pos-1)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,find_first,letter_pos-1)) > boxWidth-8 { break } } } displayed_start = find_first+1 displayed_end = letter_pos-1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) highlight_pos = cursor_pos if highlight { if letter_start_pos > displayed_end { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } else { if letter_start_pos >= displayed_start { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_start_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_start_pos-1)) } else { highlight_start_pos = 0 } } } return } else if KEY == 37 //left arrow { if (getkeystate(key_lshift)) { if highlight == false { highlight = true // letter_start_pos = letter_pos } if (getkeystate(key_lcontrol)) { if letter_pos > 1 { //Checks for the beginning of the word for find_first = letter_pos-2; find_first > 0; find_first-- { if(PasswordBox == TRUE) { if equal$(mid$(s_pword,find_first-1,find_first)," ") { break } } else { if equal$(mid$(boxValue,find_first-1,find_first)," ") { break } } } letter_pos = find_first+1 } } else { if letter_pos > 1 letter_pos-- } } else { highlight = false if (getkeystate(key_lcontrol)) { if letter_pos > 1 { //Checks for the beginning of the word for find_first = letter_pos-2; find_first > 0; find_first-- { if(PasswordBox == TRUE) { if equal$(mid$(s_pword,find_first-1,find_first)," ") { break } } else { if equal$(mid$(boxValue,find_first-1,find_first)," ") { break } } } letter_pos = find_first+1 } } else { if letter_pos > 1 { letter_pos-- } } letter_start_pos = letter_pos if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) } if letter_pos-1 < displayed_start { displayed_start = letter_pos-1 //Makes the display correct for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 } if highlight { if letter_start_pos-1 < displayed_start { highlight_start_pos = 0 } else { if letter_start_pos > displayed_end { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } else { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_start_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } } } // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos return } else if KEY == 39 //right arrow------------------------------------------------------------------------------------------------ { if (getkeystate(key_lshift)) { if highlight == false { highlight = true letter_start_pos = letter_pos } if (getkeystate(key_lcontrol)) { if letter_pos < length$(boxValue) { //Checks for the end of the word for find_first = letter_pos; find_first <= length$(boxValue)-1; find_first++ { if(PasswordBox == TRUE) { if equal$(mid$(s_pword,find_first-1,find_first)," ") { break } } else { if equal$(mid$(boxValue,find_first-1,find_first)," ") { break } } } letter_pos = find_first+1 } } else { if letter_pos <= length$(boxValue) letter_pos++ } } else { highlight = false if (getkeystate(key_lcontrol)) { if letter_pos < length$(boxValue) { //Checks for the end of the word for find_first = letter_pos; find_first <= length$(boxValue)-1; find_first++ { if(PasswordBox == TRUE) { if equal$(mid$(s_pword,find_first-1,find_first)," ") { break } } else { if equal$(mid$(boxValue,find_first-1,find_first)," ") { break } } } letter_pos = find_first+1 } } else { if letter_pos <= length$(boxValue) { letter_pos++ } } letter_start_pos = letter_pos highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) } if letter_pos > displayed_end { int for_compare //Makes the display correct for find_first = letter_pos-1; find_first > -1; find_first-- { if(PasswordBox == TRUE) for_compare = getprint3dwidth(mid$(s_pword,find_first,letter_pos-1)) else for_compare = getprint3dwidth(mid$(boxValue,find_first,letter_pos-1)) if for_compare > boxWidth-8 { break } } displayed_start = find_first+1 displayed_end = letter_pos-1 } if highlight { if letter_start_pos > displayed_end { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } else { if letter_start_pos >= displayed_start { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_start_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_start_pos-1)) } else { highlight_start_pos = 0 } } } // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos return } else if KEY == 46 //DELETE KEY { if keyboard_sound == TRUE play 2 if highlight { if (getkeystate(key_lshift)) //shift-del to cut { if(PasswordBox == TRUE) { if letter_start_pos > letter_pos setclipboard(mid$(s_pword,letter_pos-1,letter_start_pos-1)) else setclipboard(mid$(s_pword,letter_start_pos-1,letter_pos-1)) } else { if letter_start_pos > letter_pos setclipboard(mid$(boxValue,letter_pos-1,letter_start_pos-1)) else setclipboard(mid$(boxValue,letter_start_pos-1,letter_pos-1)) } } highlight = false if letter_start_pos < letter_pos { temp = left$(boxValue,letter_start_pos-1) right$(boxValue,length$(boxValue)-(letter_pos-1)) if letter_start_pos < displayed_start displayed_start = letter_start_pos-1 letter_pos = letter_start_pos } else { temp = left$(boxValue,letter_pos-1) right$(boxValue,length$(boxValue)-(letter_start_pos-1)) letter_pos = letter_pos } //Makes the display correct for find_first = displayed_start; find_first <= length$(temp); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(temp,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 if (length$(temp) < 1) { displayed_start = 0 displayed_end = 0 boxValue = "" letter_pos = 1 } if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos highlight_start_pos = cursor_pos boxValue = temp } else { if (length$(boxValue)) && letter_pos < length$(boxValue)+1 { temp = left$(boxValue,letter_pos-1) right$(boxValue,length$(boxValue)-(letter_pos)) //Makes the display correct for find_first = displayed_start; find_first <= length$(temp); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(temp,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 boxValue = temp if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos highlight_start_pos = cursor_pos } if length$(boxValue) == 0 { displayed_start = 0 displayed_end = 0 boxValue = "" letter_pos = 1 if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) } } return } key = getchar() //TODO: set in gui_focus? blink = 1 //handle backspace //TODO: only if no_edit is TRUE if ((key == 0x08) and (bl_noEdit == FALSE)) // Backspace { if keyboard_sound == TRUE play 2 if (highlight && letter_start_pos == letter_pos) highlight = false if highlight { highlight = false if letter_start_pos < letter_pos { temp = left$(boxValue,letter_start_pos-1) right$(boxValue,length$(boxValue)-(letter_pos-1)) if letter_start_pos < displayed_start displayed_start = letter_start_pos-1 letter_pos = letter_start_pos } else { temp = left$(boxValue,letter_pos-1) right$(boxValue,length$(boxValue)-(letter_start_pos-1)) letter_pos = letter_pos } //Makes the display correct for find_first = displayed_start; find_first <= length$(temp); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(temp,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 if (length$(temp) < 1) { displayed_start = 0 displayed_end = 0 boxValue = "" letter_pos = 1 } boxValue = temp if(PasswordBox == TRUE) { s_pword = 0 for(int i=0; i < length$(boxvalue); i++) s_pword = s_pword "*" } if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos highlight_start_pos = cursor_pos } else { if (length$(boxValue)) && letter_pos > 1 { temp = left$(boxValue,letter_pos-2) right$(boxValue,length$(boxValue)-(letter_pos-1)) if letter_pos-2 < displayed_start { displayed_start -= 8 if displayed_start < 0 displayed_start = 0 } //Makes the display correct for find_first = displayed_start; find_first <= length$(temp); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(temp,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 boxValue = temp if(PasswordBox == TRUE) { s_pword = 0 for(int i=0; i < length$(boxvalue); i++) s_pword = s_pword "*" } letter_pos-- if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) letter_start_pos = letter_pos highlight_start_pos = cursor_pos highlight_pos = highlight_start_pos } if (length$(boxValue) == 0) { displayed_start = 0 displayed_end = 0 boxValue = "" letter_pos = 1 if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) } } } else if(key < 1) || ((key > 1) && (key < 8)) || ((key > 8) && (key < 31)) || ((disable_forward_slash) && (key == 47)) { // ignore unprintable characters and all non-dos recognized items } else if (bl_noEdit == FALSE) { if NumericOnly { int kw = getchar() if (kw < 48 or kw > 57) return } if keyboard_sound == TRUE play 2 temp = boxValue if getkeystate(key_lcontrol) { if (key == 3) && highlight // "C" is pressed { if letter_start_pos > letter_pos { if(PasswordBox == TRUE) setclipboard(mid$(s_pword,letter_pos-1,letter_start_pos-1)) else setclipboard(mid$(boxValue,letter_pos-1,letter_start_pos-1)) } else { if(PasswordBox == TRUE) setclipboard(mid$(s_pword,letter_start_pos-1,letter_pos-1)) else setclipboard(mid$(boxValue,letter_start_pos-1,letter_pos-1)) } } if (key == 24) && highlight// "x" is pressed { if letter_start_pos > letter_pos { if(PasswordBox == TRUE) setclipboard(mid$(s_pword,letter_pos-1,letter_start_pos-1)) else setclipboard(mid$(boxValue,letter_pos-1,letter_start_pos-1)) } else { if(PasswordBox == TRUE) setclipboard(mid$(boxValue,letter_start_pos-1,letter_pos-1)) else setclipboard(mid$(boxValue,letter_pos-1,letter_start_pos-1)) } highlight = false if letter_start_pos < letter_pos { temp = left$(temp,letter_start_pos-1) right$(temp,length$(temp)-(letter_pos-1)) letter_pos = letter_start_pos } else { temp = left$(temp,letter_pos-1) right$(temp,length$(temp)-(letter_start_pos-1)) } if (length$(temp) < 1) { boxValue = chr$(key) letter_pos = 1 displayed_start = 0 displayed_end = 1 } } if (key == 22)// "V" is pressed { getclipboard(clip,boxTextLimit) cliplength = length$(clip) if highlight { if length$(temp)+cliplength-(abs(letter_start_pos-letter_pos)) <= boxTextLimit { highlight = false if letter_start_pos < letter_pos { temp = left$(temp,letter_start_pos-1) clip right$(temp,length$(temp)-(letter_pos-1)) letter_pos = letter_start_pos } else { temp = left$(temp,letter_pos-1) clip right$(temp,length$(temp)-(letter_start_pos-1)) } letter_pos += cliplength } } else { if length$(boxValue)+cliplength <= boxTextLimit { temp = left$(temp,letter_pos-1) clip right$(temp,length$(boxValue)-(letter_pos-1)) letter_pos += cliplength } } } } else { if highlight { highlight = false if letter_start_pos < letter_pos { temp = left$(temp,letter_start_pos-1) chr$(key) right$(temp,length$(temp)-(letter_pos-1)) letter_pos = letter_start_pos } else { temp = left$(temp,letter_pos-1) chr$(key) right$(temp,length$(temp)-(letter_start_pos-1)) } letter_pos++ } else { if length$(temp)+1 <= boxtextlimit { if inserttext { temp = left$(temp,letter_pos-1) chr$(key) right$(temp,length$(boxValue)-(letter_pos-1)) } else { temp = left$(temp,letter_pos-1) chr$(key) right$(temp,length$(boxValue)-(letter_pos)) } letter_pos++ } } } boxValue = temp if(PasswordBox == TRUE) { s_pword = 0 for(int i=0; i < length$(boxvalue); i++) s_pword = s_pword "*" } if(PasswordBox == TRUE) { if getprint3dwidth(s_pword) < boxWidth-8 displayed_start = 0 } else { if getprint3dwidth(boxValue) < boxWidth-8 displayed_start = 0 } if(PasswordBox == TRUE) int compare_this = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else int compare_this = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if compare_this > boxWidth-8 { //Makes the display correct for find_first = letter_pos-1; find_first > -1; find_first-- { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,find_first,letter_pos-1)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,find_first,letter_pos-1)) > boxWidth-8 { break } } } displayed_start = find_first+1 displayed_end = letter_pos-1 } else { //Makes the display correct for find_first = displayed_start; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 } if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if highlight == false { letter_start_pos = letter_pos highlight_start_pos = cursor_pos highlight_pos = highlight_start_pos } } } GUI_MAILBOX { print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 if (getmessage() == 0) { letter_pos = displayed_start+1 if letter_pos > 1 { letter_pos -= 1 } if letter_pos-1 < displayed_start { displayed_start = letter_pos-1 //Makes the display correct for find_first = displayed_start; find_first < length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_first)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_first)) > boxWidth-8 { break } } } displayed_end = find_first-1 if highlight { if letter_start_pos-1 < displayed_start { highlight_start_pos = 0 } else { if letter_start_pos > displayed_end { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } if letter_start_pos <= displayed_end { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_start_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_start_pos-1)) } } } } if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos } if (getmessage() == 1) { letter_pos = displayed_end+1 if letter_pos <= length$(boxValue) letter_pos++ if letter_pos > displayed_end { //Makes the display correct for find_first = letter_pos-1; find_first > -1; find_first-- { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,find_first,letter_pos-1)) > boxWidth-8 { break } } else { if getprint3dwidth(mid$(boxValue,find_first,letter_pos-1)) > boxWidth-8 { break } } } displayed_start = find_first+1 displayed_end = letter_pos-1 if highlight { if letter_start_pos > displayed_end { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } else { if letter_start_pos >= displayed_start { if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_start_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_start_pos-1)) } else highlight_start_pos = 0 } } } if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos } } LBUTTON_UPDATE { // if(exists(o_tabStops)) // mail(M_SELECTEVENT,o_tabStops) // else // Get the focus first if we don't have focus if gotfocus(this) == false { focus(this) } print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 if ((mouse.left == BUTTON_PRESSED) || (mouse.left == BUTTON_HELD) || (mouse.left == BUTTON_CLICKED)) { if active && over_me { for find_pos = displayed_start+1; find_pos <= length$(boxvalue); find_pos++ { if(PasswordBox == TRUE) { if getprint3dwidth(mid$(s_pword,displayed_start,find_pos)) > mouse.x-(location.x+boxTextOffset.x) { break } } else { if getprint3dwidth(mid$(boxValue,displayed_start,find_pos)) > mouse.x-(location.x+boxTextOffset.x) { break } } } letter_pos = find_pos } } if mouse.left == BUTTON_PRESSED { if active { highlight_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) cursor_pos = highlight_pos letter_pos = find_pos if letter_pos > length$(boxvalue) { letter_pos = length$(boxvalue)+1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos } highlight_start_pos = cursor_pos letter_start_pos = letter_pos } return } if (mouse.left == BUTTON_HELD && active) { if(PasswordBox == TRUE) highlight_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else highlight_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) cursor_pos = highlight_pos if letter_start_pos != letter_pos { highlight = true } if letter_pos > length$(boxvalue) { letter_pos = length$(boxvalue)+1 // cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) if(PasswordBox == TRUE) cursor_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_pos-1)) else cursor_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_pos-1)) highlight_pos = cursor_pos } return } if (mouse.left == BUTTON_CLICKED) { if timelimit > gettime() { highlight = true //Checks for the beginning of the word for find_first = letter_pos-1; find_first > 0; find_first-- { if(PasswordBox == TRUE) { if equal$(mid$(s_pword,find_first-1,find_first)," ") { break } } else { if equal$(mid$(boxValue,find_first-1,find_first)," ") { break } } } letter_start_pos = find_first+1 if(PasswordBox == TRUE) highlight_start_pos = getprint3dwidth(mid$(s_pword,displayed_start,letter_start_pos-1)) else highlight_start_pos = getprint3dwidth(mid$(boxValue,displayed_start,letter_start_pos-1)) if letter_start_pos-1 < displayed_start { highlight_start_pos = 0 } //Checks for the end of the word for find_first = letter_pos; find_first <= length$(boxValue); find_first++ { if(PasswordBox == TRUE) { if equal$(mid$(s_pword,find_first-1,find_first)," ") { break } } else { if equal$(mid$(boxValue,find_first-1,find_first)," ") { break } } } if find_first > length$(boxValue) { if(PasswordBox == TRUE) highlight_pos = getprint3dwidth(mid$(s_pword,displayed_start,find_first-1)) else highlight_pos = getprint3dwidth(mid$(boxValue,displayed_start,find_first-1)) letter_pos = find_first } else { if(PasswordBox == TRUE) highlight_pos = getprint3dwidth(mid$(s_pword,displayed_start,find_first)) else highlight_pos = getprint3dwidth(mid$(boxValue,displayed_start,find_first)) letter_pos = find_first+1 } if letter_pos > displayed_end { if(PasswordBox == TRUE) highlight_pos = getprint3dwidth(mid$(s_pword,displayed_start,displayed_end)) else highlight_pos = getprint3dwidth(mid$(boxValue,displayed_start,displayed_end)) } cursor_pos = highlight_pos } if letter_start_pos == letter_pos { highlight = false } TimeLimit = gettime()+20 } } GUI_EXECUTE { print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 if gotfocus(this) { if mouse.x < location.x && mouse.left == BUTTON_HELD { MAIL(0,this) } if mouse.x > (location.x+boxWidth) && mouse.left == BUTTON_HELD { MAIL(1,this) } if(PasswordBox == TRUE) { s_pword = 0 for(int i=0; i < length$(boxvalue); i++) s_pword = s_pword "*" } if (gotfocus(this)) { blink_count++ if blink_count > 6 { blink = !blink blink_count = 0 } } //move into initializes if(bl_noEdit == TRUE) { region = 0,0 to 0,0 } } if(PasswordBox == TRUE) displayed_text = mid$(s_pword,displayed_start,displayed_end) else displayed_text = mid$(boxValue,displayed_start,displayed_end) } GUI_DRAW { //draw box background //TODO: check if backspace causes ghost chars with no back color if(backColor) { setpencolor(backColor) drawrect location.x, location.y to location.x+boxWidth, location.y+boxHeight } //draw box border if one has been assigned if (borderColor) { setpencolor(borderColor) drawframe location.x,location.y to location.x+boxWidth,location.y+boxHeight setpencolor(shadowcolor) drawline location.x, location.y + boxHeight to location.x + boxWidth, location.y + boxHeight drawline location.x + boxWidth, location.y to location.x + boxWidth, location.y + boxHeight } // draw hot border if box has focus if (gotfocus(this) && (bl_noEdit == FALSE)) { setpencolor(selectedColor) drawframe location.x,location.y to location.x+boxWidth,location.y+boxHeight } // if (highlight) && letter_pos != letter_start_pos) { setpencolor(highlightedColor) ldrawrect boxTextOffset.x+highlight_start_pos-1,1 to boxTextOffset.x+highlight_pos,boxHeight-1 } print3d_attributes = boxFont3d,boxTextColor,1,0,1,0,0,0,1 // print text print3d_position = location.x+boxTextOffset.x, location.y+boxTextOffset.y print3d_margins = location.x, location.y to location.x+boxWidth+10,location.y+boxHeight+3 print3d displayed_text // set IME info if (gotfocus(this)) { position pos = boxTextOffset.x+cursor_pos, boxTextOffset.y makeabsolute(pos) setcaret (pos.x, pos.y) } //print blinky cursor if (gotfocus(this) && blink && (bl_noEdit == FALSE) && callback($$ImeCallback$$, 2)) { setpencolor (boxTextColor) ldrawrect boxTextOffset.x+cursor_pos, boxTextOffset.y+1 to boxTextOffset.x+cursor_pos+2,boxTextOffset.y+font_height-1 } //print label // if(!equal$(label,"")) // { print3d_attributes = labelFont3d,labelTextColor,1,0,1,0,0,0,1 lprint3d_position = offset.x, offset.y lprint3d_margins = offset.x, offset.y to 800,600//(offset.x + getprint3dwidth(label)),(offset.y + getprint3dheight(label))+3 print3d label // print3d boxvalue // print3d mouse.left // } if (bl_noEdit) { setpencolor(noEditColor) drawrect location.x,location.y to location.x+boxWidth,location.y+boxHeight } } }