Spec - TextModel whenTextIsAccepted

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Spec - TextModel whenTextIsAccepted

bahman
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)

signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

Benjamin Van Ryseghem (Pharo)
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.

Keep me in touch :)

Ben

On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]> 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)

Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

bahman
On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S) --I was expecting something like ENTER :-)

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.

Would you please explain the RHS of the statements?  I don't understand `self newTextInput`.


labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason why `autoAccept` doesn't default to true?

On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]> 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)

signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

Benjamin Van Ryseghem (Pharo)
On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S) --I was expecting something like ENTER :-)

There is also acceptOnCr :)


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.

Would you please explain the RHS of the statements?  I don't understand `self newTextInput`.

It’s equivalent to self instantiateModels: #(textName TextInputFieldModel).
It simply creates a new sub model for you :)



labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason why `autoAccept` doesn't default to true?

That’s actually a good question :)
I guess the answer is historical :)

Ben


On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]> 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)

Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

bahman
On 11/06/2013 10:56, Benjamin wrote:

> On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>> On 11/06/2013 10:41, Benjamin wrote:
>>> This is the expected behaviour :)
>>
>> Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S)
>> --I was expecting something like ENTER :-)
>
> There is also acceptOnCr :)
That clearly shows I have to work on my "exploration" skills :-)

>
>>
>>> 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.
>>
>> Would you please explain the RHS of the statements?  I don't
>> understand `self newTextInput`.
>
> It’s equivalent to self instantiateModels: #(textName
> TextInputFieldModel).
> It simply creates a new sub model for you :)
Hmm...Pharo rejects those lines, e.g. with "Unknown select
newTextInput".  I guess I'm sub-classing the wrong class.  Here's my
class definition:

<code>
ComposableModel subclass: #FirstSpec
    instanceVariableNames: 'textName labelGreeting buttonGreet'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Bahman-Spec'
</code>

>
>>
>>>
>>> labelGreeting text: ''.
>>> buttonGreet label: 'Greet Me!'; disable.
>>> textName autoAccept: true.
>>
>> It's certainly no big deal but I'm just curious; any special reason
>> why `autoAccept` doesn't default to true?
>
> That’s actually a good question :)
> I guess the answer is historical :)
Ancestral remains, huh? :-)

>
>>
>>> On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]
>>> <mailto:[hidden email]>> 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)



signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

Benjamin Van Ryseghem (Pharo)
In which version of Pharo are you working ?

Ben

On 06 Nov 2013, at 08:31, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 10:56, Benjamin wrote:
On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]
<[hidden email]>> wrote:

On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S)
--I was expecting something like ENTER :-)

There is also acceptOnCr :)

That clearly shows I have to work on my "exploration" skills :-)



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.

Would you please explain the RHS of the statements?  I don't
understand `self newTextInput`.

It’s equivalent to self instantiateModels: #(textName
TextInputFieldModel).
It simply creates a new sub model for you :)

Hmm...Pharo rejects those lines, e.g. with "Unknown select
newTextInput".  I guess I'm sub-classing the wrong class.  Here's my
class definition:

<code>
ComposableModel subclass: #FirstSpec
   instanceVariableNames: 'textName labelGreeting buttonGreet'
   classVariableNames: ''
   poolDictionaries: ''
   category: 'Bahman-Spec'
</code>




labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason
why `autoAccept` doesn't default to true?

That’s actually a good question :)
I guess the answer is historical :)

Ancestral remains, huh? :-)



On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]
<[hidden email]>> 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)



Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

bahman
On 11/06/2013 11:07, Benjamin wrote:
In which version of Pharo are you working ?

Pharo2.0
Latest update: #20607


On 06 Nov 2013, at 08:31, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 10:56, Benjamin wrote:
On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]
<[hidden email]>> wrote:

On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S)
--I was expecting something like ENTER :-)

There is also acceptOnCr :)

That clearly shows I have to work on my "exploration" skills :-)



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.

Would you please explain the RHS of the statements?  I don't
understand `self newTextInput`.

It’s equivalent to self instantiateModels: #(textName
TextInputFieldModel).
It simply creates a new sub model for you :)

Hmm...Pharo rejects those lines, e.g. with "Unknown select
newTextInput".  I guess I'm sub-classing the wrong class.  Here's my
class definition:

<code>
ComposableModel subclass: #FirstSpec
   instanceVariableNames: 'textName labelGreeting buttonGreet'
   classVariableNames: ''
   poolDictionaries: ''
   category: 'Bahman-Spec'
</code>




labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason
why `autoAccept` doesn't default to true?

That’s actually a good question :)
I guess the answer is historical :)

Ancestral remains, huh? :-)



On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]
<[hidden email]>> 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)

signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

bahman
In reply to this post by Benjamin Van Ryseghem (Pharo)
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 <[hidden email]> 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)

signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

Benjamin Van Ryseghem (Pharo)
That’s correct :)

Even if the version I proposed you to initialise widgets
textName := self newTextInput.
labelGreeting := self newLabel.
buttonGreet := self newButton.

is the new way to do it :)

Ben

On 06 Nov 2013, at 11:21, Bahman Movaqar <[hidden email]> wrote:

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 <[hidden email]> 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)

Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

Benjamin Van Ryseghem (Pharo)
In reply to this post by bahman
Ok :)

These methods only exists in Pharo 3.0 :)

Ben

On 06 Nov 2013, at 08:38, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 11:07, Benjamin wrote:
In which version of Pharo are you working ?

Pharo2.0
Latest update: #20607


On 06 Nov 2013, at 08:31, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 10:56, Benjamin wrote:
On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]
<[hidden email]>> wrote:

On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S)
--I was expecting something like ENTER :-)

There is also acceptOnCr :)

That clearly shows I have to work on my "exploration" skills :-)



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.

Would you please explain the RHS of the statements?  I don't
understand `self newTextInput`.

It’s equivalent to self instantiateModels: #(textName
TextInputFieldModel).
It simply creates a new sub model for you :)

Hmm...Pharo rejects those lines, e.g. with "Unknown select
newTextInput".  I guess I'm sub-classing the wrong class.  Here's my
class definition:

<code>
ComposableModel subclass: #FirstSpec
   instanceVariableNames: 'textName labelGreeting buttonGreet'
   classVariableNames: ''
   poolDictionaries: ''
   category: 'Bahman-Spec'
</code>




labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason
why `autoAccept` doesn't default to true?

That’s actually a good question :)
I guess the answer is historical :)

Ancestral remains, huh? :-)



On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]
<[hidden email]>> 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)

Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

bahman
On 11/06/2013 20:35, Benjamin wrote:
Ok :)

These methods only exists in Pharo 3.0 :)

Hmm...I don't understand.  Please correct me if I'm wrong but I thought Spec is a UI library, so it doesn't matter if I'm using it in Pharo 2.0 or 3.0 as long as I have the correct version of Spec.



On 06 Nov 2013, at 08:38, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 11:07, Benjamin wrote:
In which version of Pharo are you working ?

Pharo2.0
Latest update: #20607


On 06 Nov 2013, at 08:31, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 10:56, Benjamin wrote:
On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]
<[hidden email]>> wrote:

On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S)
--I was expecting something like ENTER :-)

There is also acceptOnCr :)

That clearly shows I have to work on my "exploration" skills :-)



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.

Would you please explain the RHS of the statements?  I don't
understand `self newTextInput`.

It’s equivalent to self instantiateModels: #(textName
TextInputFieldModel).
It simply creates a new sub model for you :)

Hmm...Pharo rejects those lines, e.g. with "Unknown select
newTextInput".  I guess I'm sub-classing the wrong class.  Here's my
class definition:

<code>
ComposableModel subclass: #FirstSpec
   instanceVariableNames: 'textName labelGreeting buttonGreet'
   classVariableNames: ''
   poolDictionaries: ''
   category: 'Bahman-Spec'
</code>




labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason
why `autoAccept` doesn't default to true?

That’s actually a good question :)
I guess the answer is historical :)

Ancestral remains, huh? :-)



On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]
<[hidden email]>> 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)

signature.asc (565 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spec - TextModel whenTextIsAccepted

Benjamin Van Ryseghem (Pharo)
Somehow it’s true. And you could try it :)

But while doing Spec I also fixed a lot of bugs in the morphic widgets themselves :)

Try with the latest spec, and tell me :P
Ben

On 07 Nov 2013, at 05:38, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 20:35, Benjamin wrote:
Ok :)

These methods only exists in Pharo 3.0 :)

Hmm...I don't understand.  Please correct me if I'm wrong but I thought Spec is a UI library, so it doesn't matter if I'm using it in Pharo 2.0 or 3.0 as long as I have the correct version of Spec.



On 06 Nov 2013, at 08:38, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 11:07, Benjamin wrote:
In which version of Pharo are you working ?

Pharo2.0
Latest update: #20607


On 06 Nov 2013, at 08:31, Bahman Movaqar <[hidden email]> wrote:

On 11/06/2013 10:56, Benjamin wrote:
On 06 Nov 2013, at 08:21, Bahman Movaqar <[hidden email]
<[hidden email]>> wrote:

On 11/06/2013 10:41, Benjamin wrote:
This is the expected behaviour :)

Oh!  A bit unorthodox, specially considering the shortcut (CTRL+S)
--I was expecting something like ENTER :-)

There is also acceptOnCr :)

That clearly shows I have to work on my "exploration" skills :-)



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.

Would you please explain the RHS of the statements?  I don't
understand `self newTextInput`.

It’s equivalent to self instantiateModels: #(textName
TextInputFieldModel).
It simply creates a new sub model for you :)

Hmm...Pharo rejects those lines, e.g. with "Unknown select
newTextInput".  I guess I'm sub-classing the wrong class.  Here's my
class definition:

<code>
ComposableModel subclass: #FirstSpec
   instanceVariableNames: 'textName labelGreeting buttonGreet'
   classVariableNames: ''
   poolDictionaries: ''
   category: 'Bahman-Spec'
</code>




labelGreeting text: ''.
buttonGreet label: 'Greet Me!'; disable.
textName autoAccept: true.

It's certainly no big deal but I'm just curious; any special reason
why `autoAccept` doesn't default to true?

That’s actually a good question :)
I guess the answer is historical :)

Ancestral remains, huh? :-)



On 06 Nov 2013, at 06:05, Bahman Movaqar <[hidden email]
<[hidden email]>> 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)