Hello View!! can I speak to your re-Presenter?

25 views
Skip to first unread message

F Bek

unread,
Jan 18, 2021, 10:43:26 AMJan 18
to
Beginner's question,
Dolphin Smalltalk 7.1.19

Well, now that I have a pretty compact MPV, with a Model composed of a class, a subclass, and an abstract class on top, two corresponding Presenter classes, and an abstract Presenter on top, holding a single View servicing both model classes.

I would like to access some of the View's Number/TextPresenters and even StaticText to vary their properties, and even hide/show them, depending on the calling model. 

I understand that Presenter>>onViewAvailable would be the right place to add such code, but have no idea how to identify each component of the View in order to talk to them. All I've noticed however was that the View components have some sort of id number e.g. (16r100E8E) next to their class names and names.
  
Thank you for reading and eventually answering.
FB
___________________________________________

john.a...@gmail.com

unread,
Jan 19, 2021, 4:40:42 AMJan 19
to
Hi,

Where a view is linked to a presenter (e.g. your Number/TextPresenters) you can just ask the presenter for its view, e.g.

myNumberPresenter view disable

Note you need to do this in your presenter's onViewOpened method rather than onViewAvailable, since the presenter and view are not yet linked at the point onViewAvailable is invoked.

For views without a corresponding presenter (e.g. StaticText), if you name them in the View Composer (set their 'name' aspect to a String) you can look them up by that name, e.g.

(self view viewNamed: 'myLabel') text: 'This is a label'

Hope this helps.

John

F Bek

unread,
Jan 19, 2021, 5:06:30 AMJan 19
to
Thanks John, this is great. 
Experimenting!
Regards,
FB
___________________________________________

F Bek

unread,
Jan 19, 2021, 5:37:25 AMJan 19
to
Works like a charm! Thanks again John!
_____________________________________________
Reply all
Reply to author
Forward
0 new messages