diff options
Diffstat (limited to 'pharo-mooc/tiny-chat/src/TinyChat-client/TCConsole.class.st')
| -rw-r--r-- | pharo-mooc/tiny-chat/src/TinyChat-client/TCConsole.class.st | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/pharo-mooc/tiny-chat/src/TinyChat-client/TCConsole.class.st b/pharo-mooc/tiny-chat/src/TinyChat-client/TCConsole.class.st new file mode 100644 index 0000000..3f7055e --- /dev/null +++ b/pharo-mooc/tiny-chat/src/TinyChat-client/TCConsole.class.st @@ -0,0 +1,62 @@ +Class { + #name : 'TCConsole', + #superclass : 'SpPresenter', + #instVars : [ + 'chat', + 'list', + 'input' + ], + #category : 'TinyChat-client', + #package : 'TinyChat-client' +} + +{ #category : 'as yet unclassified' } +TCConsole class >> attach: aTinyChat [ + + | window | + window := self new chat: aTinyChat. + window open whenClosedDo: [ aTinyChat disconnect ]. + ^ window +] + +{ #category : 'as yet unclassified' } +TCConsole class >> defaultLayout [ + ^ SpBoxLayout newTopToBottom + add: #list; add: #input; yourself +] + +{ #category : 'accessing' } +TCConsole >> chat: anObject [ + chat := anObject +] + +{ #category : 'accessing' } +TCConsole >> initializeWidgets [ + + list := SpListPresenter new. + input := SpTextInputFieldPresenter new + placeholder: 'Type your message here...'; + enabled: true; + whenSubmitDo: [ :string | chat send: string. input text: '' ]. + self focusOrder add: input +] + +{ #category : 'accessing' } +TCConsole >> input [ + ^ input +] + +{ #category : 'accessing' } +TCConsole >> list [ + ^ list +] + +{ #category : 'accessing' } +TCConsole >> print: aCollectionOfMessages [ + list items: (aCollectionOfMessages collect: [ :m | m printString ]) +] + +{ #category : 'accessing' } +TCConsole >> title [ + ^ 'TinyChat' +] |
