Changing button text in response to a message

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

Changing button text in response to a message

Bob Jarvis
I'm suffering from serious brain-fade and can't figure this out.  Help
greatly appreciated.

I've got a view on a Shell subclass which has a bunch of sub-views.
Buried down in the subviews is a PushButton named 'showMessages'.
When I click the pushbutton the proper command is generated and I
receive it very happily in my Shell subclass.  When the message is
received I want to change the text of the button, but I can't figure
out HOW to change the button text.  I've tried

    (self view viewNamed: 'showMessages') text: 'Show All Msgs'

but I get an error from ShellView(ContainerView)>>viewNamed:ifNone:
saying

    Not found: showMessages

I've tried hooking a BooleanPresenter to the pushbutton and changing
the text through the presenter, but the text doesn't change.

Can some kind soul please point me in the correct direction?  Thanks.


Reply | Threaded
Open this post in threaded view
|

Re: Changing button text in response to a message

Christopher J. Demers
Bob Jarvis <[hidden email]> wrote in message
news:[hidden email]...
...
> received I want to change the text of the button, but I can't figure
> out HOW to change the button text.  I've tried
>
>     (self view viewNamed: 'showMessages') text: 'Show All Msgs'
>
> but I get an error from ShellView(ContainerView)>>viewNamed:ifNone:
> saying
>
>     Not found: showMessages

I just tried something like this, and it works for me.  Make sure your
button is REALLY named.  I normally do not name my buttons, because the
command symbol is used like a name to display it in the list of views and I
don't normally need to refer to them.  Perhaps your button is not named and
you are trying to use the command name to refer to it?

BTW: I have a little goody ( http://www.mitchellscientific.com/smalltalk/ )
that allows a drag/drop visual selection of a view, and it can used to
inspect the view.  It can be handy to inspect a view sometimes to see if it
really has what you expect it to.  You can look at the names instance
variable to see all the named controls and test code in the inspector.

Good luck,
Chris


Reply | Threaded
Open this post in threaded view
|

Re: Changing button text in response to a message

Ian Bartholomew-6
In reply to this post by Bob Jarvis
Bob,

>     (self view viewNamed: 'showMessages') text: 'Show All Msgs'
>
> but I get an error from ShellView(ContainerView)>>viewNamed:ifNone:
> saying
>
>     Not found: showMessages

That should work. I tried it in 6 nested containers and it found the button
without any trouble.

About the only thing I can think of that you might not have tried is
checking for a trailing space on the name where it is defined in the view.
That can be a bit difficult to spot.

My only other suggestion is to enumerate all the subviews using

YourShell show view allSubViews

and look through the list to see if you can spot anything untoward.

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: Changing button text in response to a message

Bill Schwab-2
Bob,

> About the only thing I can think of that you might not have tried is
> checking for a trailing space on the name where it is defined in the view.
> That can be a bit difficult to spot.
>
> My only other suggestion is to enumerate all the subviews using
>
> YourShell show view allSubViews
>
> and look through the list to see if you can spot anything untoward.

Have you tried Snoop - it's one of Ian's goodies, and is great for looking
through a "running" view.

Good luck!

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Changing button text in response to a message

Don Rylander-3
In reply to this post by Bob Jarvis
Bob,

If it's a command button, the simplest way to do it might be through the
#queryCommand: mechanism.  IIRC, when you enable the command, you can also set
the text associated with it, which then gets passed to the screen elements as
they are enabled or disabled.  Take a look at CommandQuery instance-side
methods.  Note that the text can change regardless of whether the button state
changes.

Don

"Bob Jarvis" <[hidden email]> wrote in message
news:[hidden email]...

> I'm suffering from serious brain-fade and can't figure this out.  Help
> greatly appreciated.
>
> I've got a view on a Shell subclass which has a bunch of sub-views.
> Buried down in the subviews is a PushButton named 'showMessages'.
> When I click the pushbutton the proper command is generated and I
> receive it very happily in my Shell subclass.  When the message is
> received I want to change the text of the button, but I can't figure
> out HOW to change the button text.  I've tried
>
>     (self view viewNamed: 'showMessages') text: 'Show All Msgs'
>
> but I get an error from ShellView(ContainerView)>>viewNamed:ifNone:
> saying
>
>     Not found: showMessages
>
> I've tried hooking a BooleanPresenter to the pushbutton and changing
> the text through the presenter, but the text doesn't change.
>
> Can some kind soul please point me in the correct direction?  Thanks.


Reply | Threaded
Open this post in threaded view
|

Re: Changing button text in response to a message

Bob Jarvis
In reply to this post by Bob Jarvis
As some surmised the button wasn't named properly.  (I've really got
to do more UI programming in Dolphin in order to get more accustomed
to it).

Thanks much to all who responded.