StatusBar - how to display a string?

39 views
Skip to first unread message

F Bek

unread,
Feb 17, 2021, 8:16:12 PMFeb 17
to
Beginner's question
Dolphin Smalltalk 7.2.6

How do you get the Status Bar to display a string?

I can communicate with the Status Bar from a Presenter with say <(self view viewNamed: 'bar')>, but how do I get it to display anything, and update itself? Both #value: and #text: are not understood.

And more generally, how do I add items to the StatusBar and use them?

Thanks for reading and eventually answering.
FB

___________________________________________

john.a...@gmail.com

unread,
Feb 18, 2021, 11:54:53 AMFeb 18
to
Hi FB,

You can add individual fields (StatusBarItems) to a StatusBar in the View Composer - look for its 'items' aspect, you add/edit/remove/reorder items in the same way as a ListView's columns.

If you name the StatusBarItems you can then either address them directly via their name (self view viewNamed: 'barItem'), or create a correspondingly-named TextPresenter and use them like a 'normal' text view/presenter pair.

Hope this helps.

John

F Bek

unread,
Feb 18, 2021, 6:07:43 PMFeb 18
to
Thanks John,
Indeed, StatusBar comes with one (StatusBarItem) and following your message, I added another one for the sake of trying, named it 'bar' and adjusted its (width) from the default (-1) to say (120) so the box extent and separators are clearly visible.

I am still stuck on trying to communicate anything with it: trying, from within <onViewOpened> the following: (self view viewNamed: 'bar') text: 'xyz' or #value: both selectors produce a 'not understood' error, while #displayString: 'xyz' doesn't produce an error but doesn't produce a result either.. Is there a missing step to designate it as text box first (or icon, button, image, or anything else)?

Do I have to drop a (TextEdit) on top of it? which I have done and, in the hierarchy tree, it shows as a child to the (StatusBar). But then, I am communicating with the (TextEdit), which has its own 'name', and not with the (StatusBarItem), which doesn't seem to do much, but looks like a decorator only!?

It seems like I am missing on the main concept here. Any further clarifications would be much appreciated.
FB
___________________

john.a...@gmail.com

unread,
Feb 19, 2021, 4:53:04 AMFeb 19
to
Try:

(self view viewNamed: 'bar') model value: 'xyz'

You can decouple the direct reference to the view by creating your own ValueModel (held in an inst var) and assigning this to the item, then addressing updates to the model, e.g.

barModel

^barModel ifNil: [barModel := ValueHolder new]

onViewOpened

super onViewOpened.
(self view viewNamed: 'bar') model: self barModel

You should then be able to update the status bar item via the model, e.g.

self barModel value: 'hello'

HTH.

John

F Bek

unread,
Feb 19, 2021, 7:54:58 PMFeb 19
to
I tried the ValueHolder way and it kinda worked, but with some weird side effects: 

First - the main view just remembered that it should be transparent, and as it was drawn on the screen, the main view background just disappeared and became a screen shot to whatever was below it on the desktop, albeit with a bit of scaling up. But when instruction <self barModel value: 'hello'> was commented out, this effect disappeared, and the view background returned to the default white. And when the <isTransparent> property was set to 'false' in 'View Composer', the effect disappeared also - fair game, as this should have been set to 'false' in the first place? But then, why only now?

Second - the Status Bar doesn't only show the string, in this case ( hello ), but it precedes it with the symbol ( 'U' ), which is Dolphin's class icon for UTF-encoded strings. And, after a few trials, it seems that whatever the displayed object is (Float, Integer, Point, etc.), it is always preceded by its class icon - not really the desired effect. I didn't find a fix for this yet!

What am I doing wrong?

______________________________________

john.a...@gmail.com

unread,
Feb 22, 2021, 5:35:36 AMFeb 22
to
I'm not sure what's happening with the transparency issue, but you can get rid of the icon by setting the StatusBarItem's getImageBlock to nil.

F Bek

unread,
Feb 22, 2021, 9:05:06 AMFeb 22
to
Indeed, setting 'getImageBlock' to 'nil' resolved the issue. I've included that in the <onViewOpened > method (couldn't find a way to do it in View Composer):
(self view viewNamed: 'bar') model: self barModel ; getImageBlock: nil .

I'll leave the transparency issue for now, until I (re)check a few more issues...

Thanks and best regards,
FB
----------------------------------------

john.a...@gmail.com

unread,
Feb 22, 2021, 9:44:22 AMFeb 22
to
> (couldn't find a way to do it in View Composer):

Either double-click the item, change the code to nil and click the green tick, or just right-click the item and select 'Set to Nil'

Cheers.

John

F Bek

unread,
Feb 22, 2021, 12:57:46 PMFeb 22
to
Of course! I don't know how I missed that, though I tried. This time, it worked.

Thanks & regards,
FB
_____________________________________
Reply all
Reply to author
Forward
0 new messages