How to create a TextMorph with Text containing links

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

How to create a TextMorph with Text containing links

Christian Kellermann
Hi List!

I want to program a gopher client in squeak and I am a bit stuck
on how to do the rendering.  I got the hint that I could use a
TextMorph since there links are a text attribute.

However I am a bit clueless on how this is supposed to fit together.

What I did atm was that for gopher menus I have an OrderedCollection of MenuItems.
Those in turn have implemented their #asText methods. For links I
am returning TextURL objects there.

This is all collected in a GopherPage's #asText method where said
orderedCollection is #join'ed together.

As it turns out though, the TextMorph will render my URL as if the
#printOn: message has been sent to it.  TextURLs will show up in
the TextMorph as 'a TextURL'. My guess is that the #join is responsible
for this.

How am I supposed to add URLs into Text?

Kind regards,

Christian



--
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to create a TextMorph with Text containing links

Ben Coman


On Fri, 14 Sep 2018 at 22:56, Christian Kellermann <[hidden email]> wrote:
Hi List!

I want to program a gopher client in squeak and I am a bit stuck
on how to do the rendering.  I got the hint that I could use a
TextMorph since there links are a text attribute.

However I am a bit clueless on how this is supposed to fit together.

What I did atm was that for gopher menus I have an OrderedCollection of MenuItems.
Those in turn have implemented their #asText methods. For links I
am returning TextURL objects there.

This is all collected in a GopherPage's #asText method where said
orderedCollection is #join'ed together.

As it turns out though, the TextMorph will render my URL as if the
#printOn: message has been sent to it.  TextURLs will show up in
the TextMorph as 'a TextURL'. My guess is that the #join is responsible
for this.

How am I supposed to add URLs into Text?

Here is something I recently did in Pharo.  I expect these parts of the systems are very similar.

linkText := url asText
addAttribute: (TextAction new actOnClickBlock: [ExternalWebBrowser new open: url]);
addAttribute: TextColor blue;
addAttribute: TextEmphasis underlined.
tm := TextMorph new.
tm contents:  linkText.
tm openInWindow

You'll need to find an appropriate "ExternalWebBrowser" library for your Squeak version.   

cheers -ben

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to create a TextMorph with Text containing links

Christian Kellermann
* Ben Coman <[hidden email]> [180915 02:46]:
> Here is something I recently did in Pharo.  I expect these parts of the
> systems are very similar.

Ah thanks that's been the nudge in the right direction! I am using
a PluggableTextAttribute now which also allows specifying a block...

I am hitting another bunp in that it seems just adding a TextMorph
to a SystemWindow -> ScrollPane -> PasteUpMorph.  (-> meaning
'containing a') does not make it scrollable...

Should I compose the content of individual TextMorphs? Or am I
missing something obvious?

Kind regards,

Christian

--
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to create a TextMorph with Text containing links

Christian Kellermann
* Christian Kellermann <[hidden email]> [180915 16:59]:

> * Ben Coman <[hidden email]> [180915 02:46]:
> > Here is something I recently did in Pharo.  I expect these parts of the
> > systems are very similar.
>
> Ah thanks that's been the nudge in the right direction! I am using
> a PluggableTextAttribute now which also allows specifying a block...
>
> I am hitting another bunp in that it seems just adding a TextMorph
> to a SystemWindow -> ScrollPane -> PasteUpMorph.  (-> meaning
> 'containing a') does not make it scrollable...
>
> Should I compose the content of individual TextMorphs? Or am I
> missing something obvious?
Ah nvm, I had something like this:

scrollPane := ScrollPane new
  scroller addMorph: pasteUpMorph.
which is sending the message to the wrong receiver it seems :)

--
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

signature.asc (817 bytes) Download Attachment