Changing button text in response to a message 
Author Message
 Changing button text in response to a message

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.



Wed, 04 Aug 2004 05:45:31 GMT  
 Changing button text in response to a message

...

Quote:
> 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



Wed, 04 Aug 2004 06:14:16 GMT  
 Changing button text in response to a message
Bob,

Quote:
>     (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



Wed, 04 Aug 2004 06:43:35 GMT  
 Changing button text in response to a message
Bob,

Quote:
> 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.



Wed, 04 Aug 2004 08:16:04 GMT  
 Changing button text in response to a message
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


Quote:
> 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.



Sat, 07 Aug 2004 00:12:24 GMT  
 Changing button text in response to a message
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.



Sat, 07 Aug 2004 03:27:59 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Changing the text color of a button in ObjectStudio

2. Changing button text on the fly

3. why is text on delete button changing

4. Changing button-text at runtime ??

5. How to change the text of a button?

6. changing text on buttons of tk_messageBox

7. change text of a check button

8. Radio Buttons & Change Button

9. changing the size of the check button on a check button menu entry

10. button text as value in button's command

11. button size in pixel for a text button

12. changing record(after deleting CHANGE button)

 

 
Powered by phpBB® Forum Software