Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
First attempt with text field input
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed May 25, 2021
1 parent 3efdca5 commit 0c0de8f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Spec-Brick-Tests/SpBrickTextInputFieldAdapterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Class {
#name : #SpBrickTextInputFieldAdapterTest,
#superclass : #SpBrickWidgetAdapterTest,
#category : #'Spec-Brick-Tests'
}

{ #category : #tests }
SpBrickTextInputFieldAdapterTest >> specWidgetClass [

^ SpTextInputFieldPresenter
]

{ #category : #tests }
SpBrickTextInputFieldAdapterTest >> testText [

specWidget text: 'Hello Brick'.
self assert: specWidget text asString equals: 'Hello Brick'.

brickWidget text: 'Hello Spec' asRopedText.
" self waitUI."
self assert: specWidget text asString equals: 'Hello Spec'.

]
12 changes: 12 additions & 0 deletions src/Spec-Brick/BrOneLineInputFilter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Class {
#name : #BrOneLineInputFilter,
#superclass : #BrTextEditorInputFilter,
#category : #'Spec-Brick'
}

{ #category : #accessing }
BrOneLineInputFilter >> filter: aString [
<return: #String>

^ aString reject: #isLineSeparator
]
35 changes: 35 additions & 0 deletions src/Spec-Brick/SpBrickAbstractTextAdapter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Class {
#name : #SpBrickAbstractTextAdapter,
#superclass : #SpBrickWidgetAdapter,
#category : #'Spec-Brick'
}

{ #category : #'widget creation' }
SpBrickAbstractTextAdapter >> subscribeToPresenter [

self presenter
whenTextChangedDo: [ self updateText ];
whenPlaceholderChangedDo: [ self halt ];
whenAcceptBlockChangedDo: [ self halt ];
yourself
]

{ #category : #'widget creation' }
SpBrickAbstractTextAdapter >> subscribeToWidget [

widget
addEventHandlerOn: "BrEditorTextChanged"BrTextEditorModifiedEvent
do: [ self updateText ]
]

{ #category : #'widget update' }
SpBrickAbstractTextAdapter >> updateAll [

self updateText.
]

{ #category : #'widget update' }
SpBrickAbstractTextAdapter >> updateText [

self subclassResponsibility
]
21 changes: 21 additions & 0 deletions src/Spec-Brick/SpBrickTextInputFieldAdapter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Class {
#name : #SpBrickTextInputFieldAdapter,
#superclass : #SpBrickAbstractTextAdapter,
#category : #'Spec-Brick'
}

{ #category : #'widget creation' }
SpBrickTextInputFieldAdapter >> buildWidget [

^ BrEditor new
aptitude: BrGlamorousRegularEditorAptitude;
inputFilter: BrOneLineInputFilter new;
vFitContent;
yourself
]

{ #category : #'widget update' }
SpBrickTextInputFieldAdapter >> updateText [

self widgetDo: [ :w | w text: self presenter text ]
]

0 comments on commit 0c0de8f

Please sign in to comment.