View Single Post
Old 10-17-2015, 03:20 AM   #70
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,442
Default User Interface: simple Text Line Editor

Code:
desc: edit 
//tags: User Interface
//author: mschnell

in_pin:none
in_pin:none
options:want_all_kb

         
    
@init                 

@gfx 60, 30

cc = gfx_getchar();
cc > 1 ? (
  cc >= 32 ? (
    strlen(#s) < 20 ? (
      c = cc;
      #sc = ".";
      str_setchar(#sc, 0, c);
      #s += #sc;
    );  
   ) : cc == 8 ? (                            // Backspace
    strcpy_substr(#s, #s, 0, strlen(#s)-1);
   ) :  cc == 13 ? (                          // Enter: acknowlage this text
    #ss = #s;
    #s = "";    
   ) : (
    #s = #ss;                        // other keys: Use latest acknowlaged Text as Edit Template
  );  
);



gfx_clear=0xC0C0C0; // set clearing to "gray".
gfx_a=1; // alpha 1.0
gfx_setfont(1,"Arial",20,'b');  
gfx_x = 10;
gfx_y = 10;
strlen(#s) == 0 ? (
  gfx_r = 1;
  gfx_g = 0;
  gfx_b = 0;
  gfx_drawstr(#ss);
 ) : (
  gfx_r = 0;
  gfx_g = 0;
  gfx_b = 0;
  gfx_drawstr(#s);
)
mschnell is offline   Reply With Quote