简体   繁体   中英

Pharo: how to open a Transcript if none is open

I would like to know whether a Transcript window is visible, and if not to open one.

Since the model behind a Transcript is a PluggableTextMorph I thought about collecting all those which represent Transcripts with

PluggableTextMorph allInstances select: [ :e| e model = Transcript ]

This is all nice, returns a bunch of objects. However, it's not clear which of these is visible. Probably a beginner Morphic question... :)

Maybe there is a better way, but you can definitely use this:

World submorphs
  detect: [ :m | m model = Transcript ]
  ifNone: [ Transcript open ]

or

SystemWindow allInstances detect: [ :m | m model = Transcript ] ifNone: [ Transcript open ]

The thing is that I've tried to do

ThreadSafeTranscriptPluggableTextMorph allInstances detect: ...

but for some reason morph is still alive even if window is closed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM