blob: 3f7055ea3be2407d2465372348339a46c1dac876 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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'
]
|