Posted to tcl by aspect at Wed Jul 01 08:12:46 GMT 2015view raw

  1. # itext - can't move insertion cursor
  2. # nstext - can't select
  3. package require Tk
  4. package require snit
  5. package provide itext 0.1
  6.  
  7.  
  8. ::snit::widgetadaptor itext {
  9.  
  10. constructor {args} {
  11. installhull using text
  12.  
  13. # Apply an options passed at creation time.
  14. $self configurelist $args
  15. }
  16.  
  17. delegate method Mark to hull as mark
  18.  
  19. method mark {cmd args} {
  20. if {$cmd eq "set" && [lindex $args 0] eq "insert"} {
  21. puts "$self $cmd {*}$args"
  22. return
  23. }
  24. $self Mark $cmd {*}$args
  25. }
  26.  
  27. # Pass all other methods and options to the real text widget, so
  28. # that the remaining behavior is as expected.
  29. delegate method * to hull
  30. delegate option * to hull
  31. }
  32.  
  33. ::snit::widgetadaptor nstext {
  34.  
  35. constructor {args} {
  36. installhull using text
  37.  
  38. # Apply an options passed at creation time.
  39. $self configurelist $args
  40. }
  41.  
  42. delegate method Tag to hull as tag
  43.  
  44. method tag {cmd args} {
  45. if {$cmd eq "add" && [lindex $args 0] eq "sel"} {
  46. puts "$self $cmd {*}$args"
  47. return
  48. }
  49. $self Tag $cmd {*}$args
  50. }
  51.  
  52. # Pass all other methods and options to the real text widget, so
  53. # that the remaining behavior is as expected.
  54. delegate method * to hull
  55. delegate option * to hull
  56. }
  57.  
  58. pack [itext .i]
  59. pack [nstext .ni]
  60.