Changing Static Text Programmatically

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

Changing Static Text Programmatically

acg
Hello
 In other ST's, I have used Static Text, rather than EntryField (in
ST/V) or InputField (in VW), and modified the programmatically, mainly
to get rid of the entry field border and have the cursor not change
when going over the field.

I have noticed that when I try set the text aspect in View Composer on
either a TextPresenter.Static Text (with text='Some Default Text',
name='staticTextPresenter') or TextPresenter.Default view (with
isReadOnly=true, isStatic=true, text='Some Default Text',
name='staticTextPresenter' ), everything looks good until I put:

 self add: TextPresenter new name: 'staticTextPresenter'  in
>>createComponents.

The after 'MyTestShell show', the static text appears to reset to empty
string

So my work around is to use:

 (self add: TextPresenter new name: 'staticTextPresenter') value: 'Some
Default Text'

and later programmatically change the text again with:

(self presenterNamed: 'staticTextPresenter') value: 'New Text'

I also noticed that when I try to the same sort of thing,  with a
TextPresenter opening with some default text. The text is not there,
but can be set in #onViewOpened with:

'namePresenter value: 'Enter your Name'

which was set-up in #createComponents as:

 namePresenter := self add: TextPresenter new name: 'namePresenter'.

but:

 namePresenter value: 'Enter your Name'  place in #createComponents.

executed, but also reset to empty string, on launch.

Any others experience this, or other suggested work arounds.

Thanks
ACG


Reply | Threaded
Open this post in threaded view
|

Re: Changing Static Text Programmatically

Support at Object Arts
"acg" <[hidden email]> wrote in message
news:[hidden email]...

> Hello
> In other ST's, I have used Static Text, rather than EntryField (in
> ST/V) or InputField (in VW), and modified the programmatically, mainly
> to get rid of the entry field border and have the cursor not change
> when going over the field.
>
> I have noticed that when I try set the text aspect in View Composer on
> either a TextPresenter.Static Text (with text='Some Default Text',
> name='staticTextPresenter') or TextPresenter.Default view (with
> isReadOnly=true, isStatic=true, text='Some Default Text',
> name='staticTextPresenter' ), everything looks good until I put:
>
> self add: TextPresenter new name: 'staticTextPresenter'  in
>>>createComponents.
>

Don't attach a TextPresenter (which will wire up default model containing
the empty string), but rather access the view directly. Look for references
to #viewNamed: to see how to access the view directly, bearing in mind that
the view is not available at the #createComponents stage. You can rely on
its presence in/after #onViewOpened

HTH

OA


acg
Reply | Threaded
Open this post in threaded view
|

Re: Changing Static Text Programmatically

acg
> Don't attach a TextPresenter (which will wire up default model containing
> the empty string), but rather access the view directly...

Hello
Thanks for the speedy reply.

 (self view viewNamed: 'staticTextPresenter) text: 'New Words'

is more elegant, than my work around of

(self add: TextPresenter new name: 'staticTextPresenter) value:
'Words'.

 in #createComponents.

then changing with:

 (self presenterNamed: 'staticTextPresenter) value: 'New Words'.

Accessing the view directly had not occured to me.

Thanks Again
ACG