On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :) But what you can do (and actually what you wanna do) is to accept the text at each keyStroke :)
initializePresenter self instantiateModels: #( textName TextModel labelGreeting LabelModel buttonGreet ButtonModel ). labelGreeting text: ''. buttonGreet label: 'Greet Me!'; disable.
should be turned into:
#initializePresenter textName := self newTextInput. labelGreeting := self newLabel. buttonGreet := self newButton.
labelGreeting text: ''. buttonGreet label: 'Greet Me!'; disable. textName autoAccept: true.
Just got home and tried autoAccept and got a "MessageNotUnderstood: TextModel>>autoAccept:" error. Though after changing `initializeWidgets` to the following, it worked as expected: <code> self instantiateModels: #( textName TextInputFieldModel labelGreeting LabelModel buttonGreet ButtonModel ). </code> Is what I have done the right way to do it?
Keep me in touch :)
Ben
On 06 Nov 2013, at 06:05, Bahman Movaqar <Bahman@BahmanM.com <mailto:Bahman@BahmanM.com>> wrote:
Hi all,
I'm writing a simple graphical version of the legendary "Hello, world". I have a window with a text field, a button and a label. What I'm trying to do is to make the button (which is initially disabled) enabled upon user entering text. However, it seems that the user first must "Accept" the text for the action to be fired.
Here's some snippets of code:
<code> initializePresenter textName whenTextChanged: [ buttonGreet enable ]. buttonGreet action: [ labelGreeting text: 'Hello, ', textName text, '!'. buttonGreet disable ].
initializeWidgets self instantiateModels: #( textName TextModel labelGreeting LabelModel buttonGreet ButtonModel ).
labelGreeting text: ''. buttonGreet label: 'Greet Me!'; disable. </code>
What am I doing wrong?
TIA,
PS: I have tried `whenTextChanged` to no avail --it shows the same behaviour.
-- Bahman Movaqar (http://BahmanM.com) ERP Evaluation, Implementation & Deployment Consultant PGP Key ID: 0x6AB5BD68 (keyserver2.pgp.com)