Moka-Controllers.st 1.4 KB

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