Advertisement
adriweb

Untitled

Aug 27th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. require "color"
  2.  
  3. pww, pwh = platform.window:width(), platform.window:height()
  4.  
  5. toolpalette.register({
  6.     {"Couleur",  
  7.         {"bleu", function() setTBcolor(color.blue) end},  
  8.         {"vert", function() setTBcolor(color.green) end}
  9.     }
  10. })
  11. toolpalette.enableCopy(true)
  12. toolpalette.enableCut(true)
  13. toolpalette.enablePaste(true)
  14.  
  15. function on.construction()
  16.     TB = D2Editor.newRichText()
  17.          :setFontSize(45)    
  18.          :resize(pww-1, pwh-1)    
  19.          :move(0,0)  
  20.          :setBorder(1)
  21.          :registerFilter({
  22.                             charIn = function(c)
  23.                                 print(c)
  24.                                 return false -- on ignore l'event, on le laisse se propager
  25.                             end,
  26.                             arrowKey = function(a)
  27.                                 print(a)
  28.                                 return false -- on ignore l'event, on le laisse se propager
  29.                             end,
  30.                             tabKey = function(a)
  31.                                 print("tab reΓ§u")
  32.                                 return true -- on catche l'event, on ne le laisse pas se propager
  33.                             end,
  34.                           })
  35. end
  36.  
  37. function setTBcolor(color)
  38.     TB:setBorderColor(color)
  39.       :setTextColor(color)
  40.       :setText(TB:getText() or "") -- Why doesn't TI automatically refreshes the text, good question...
  41. end
  42.  
  43. function on.resize(w, h)
  44.     pww, pwh = w, h
  45.     TB:resize(pww, pwh)
  46.     platform.window:invalidate()
  47. end
  48.  
  49. function on.getFocus()
  50.     TB:setFocus(true)
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement