Moka-Controllers.st 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. Smalltalk current createPackage: 'Moka-Controllers'!
  2. MKAspectController subclass: #MKAnyKeyInputController
  3. instanceVariableNames: 'lastValue'
  4. package: 'Moka-Controllers'!
  5. !MKAnyKeyInputController commentStamp!
  6. I am the default controller for `MKTextAreaView`. Actions are performed on any key press if the view's value changes.!
  7. !MKAnyKeyInputController methodsFor: 'accessing'!
  8. inputText
  9. ^ self view value
  10. ! !
  11. !MKAnyKeyInputController methodsFor: 'actions'!
  12. onKeyPressed: anEvent
  13. | newValue |
  14. newValue := self inputText.
  15. newValue = lastValue ifTrue: [ ^ self ].
  16. lastValue := newValue.
  17. self performActionWith: newValue
  18. ! !
  19. MKAnyKeyInputController subclass: #MKEnterInputController
  20. instanceVariableNames: ''
  21. package: 'Moka-Controllers'!
  22. !MKEnterInputController commentStamp!
  23. I am the default controller for `MKInputView`.
  24. Actions are performed on 'enter' key press.!
  25. !MKEnterInputController methodsFor: 'actions'!
  26. onKeyPressed: anEvent
  27. anEvent keyCode = String cr asciiValue ifTrue: [
  28. super onKeyPressed: anEvent ]
  29. ! !
  30. MKAspectController subclass: #MKButtonController
  31. instanceVariableNames: ''
  32. package: 'Moka-Controllers'!
  33. !MKButtonController commentStamp!
  34. I am the default controller for `MKButtonView`.!
  35. !MKButtonController methodsFor: 'actions'!
  36. onPressed
  37. self performAction
  38. ! !
  39. MKAspectController subclass: #MKCheckboxController
  40. instanceVariableNames: ''
  41. package: 'Moka-Controllers'!
  42. !MKCheckboxController commentStamp!
  43. I am the default controller for `MKCheckboxView`.!
  44. !MKCheckboxController methodsFor: 'actions'!
  45. onToggled: aBoolean
  46. self performActionWith: aBoolean
  47. ! !