Discussion:
[lively-kernel] Three quick questions
Rick McGeer
2014-05-26 01:29:55 UTC
Permalink
1. I'm having this odd behavior where $world.onFocus() is getting
overwritten on a $world.saveWorld(). Specifically, I set $world.onFocus to
a function which assigns the focus to a specific morph on the page
($world.get('2048Board').get('Board').focus()). This works fine, and when
I click away from the tab and back to it the focus is assigned correctly.
I can also look at $world.onFocus and see it's the correct function.
However, after I do a $world.saveWorld() and then reload the page, I get
the default $world.onFocus method, not the one I wrote. Is this a bug, or
is there something I'm doing wrong?
2. Is there a preferred way of doing hyperlinks? I can think of at
least two, and I'm sure that there are more. The two I've thought of are
to use an HTMLWrapperMorph, and to attach an onMouseDown event, but I
guarantee there's a third way, and the third way is better. I know there's
a third way because I've looked at the source for the welcome page, and the
hyperlinks are in text morphs, which turn into <span>s in the HTML source,
and the links themselves are <uri> tags in the span. My problem is I don't
know how to create this using Morphic (it may be I am just slow today).
The hell of it is, I knew how to do it once, because I put the link to
Lively Cheat Sheet on the Welcome page (I wanted to put the link to
Robert's marvelous Lively 101 page there, too, but more important I wanted
to figure out how to do this....sorry for the dumb question)
3. Is there a way to flatten a morph or (equivalently) generate an image
file for a morph? The specific case I'm thinking of is where one builds up
a complex image from lots of submorphs, but once done doesn't want to
manipulate the submorphs anymore...just bake the thing in place.
t***@gmail.com
2014-05-26 07:27:56 UTC
Permalink
Hi




Re 1: I think the functions on the world may just not be serialized usually, but it works for me if you do

$world.addScript(function onFocus(evt) {
alertOK("World focus")
if (!this.isFocusable()) { this.blur(); return };
lively.morphic.Morph.prototype._focusedMorph = this;
})





Re 2: The Shortcuts documentation says you can add links with CMD+K




Re 3: I did that once for PartsBin screenshots. This issue describes how it can be done: https://github.com/LivelyKernel/LivelyKernel/issues/248




Hope that helps,

Tim






From: Rick McGeer
Sent: ‎Monday‎, ‎May‎ ‎26‎, ‎2014 ‎3‎:‎29‎ ‎AM
To: lively-***@hpi.uni-potsdam.de





I'm having this odd behavior where $world.onFocus() is getting overwritten on a $world.saveWorld(). Specifically, I set $world.onFocus to a function which assigns the focus to a specific morph on the page ($world.get('2048Board').get('Board').focus()). This works fine, and when I click away from the tab and back to it the focus is assigned correctly. I can also look at $world.onFocus and see it's the correct function. However, after I do a $world.saveWorld() and then reload the page, I get the default $world.onFocus method, not the one I wrote. Is this a bug, or is there something I'm doing wrong?
Is there a preferred way of doing hyperlinks? I can think of at least two, and I'm sure that there are more. The two I've thought of are to use an HTMLWrapperMorph, and to attach an onMouseDown event, but I guarantee there's a third way, and the third way is better. I know there's a third way because I've looked at the source for the welcome page, and the hyperlinks are in text morphs, which turn into <span>s in the HTML source, and the links themselves are <uri> tags in the span. My problem is I don't know how to create this using Morphic (it may be I am just slow today). The hell of it is, I knew how to do it once, because I put the link to Lively Cheat Sheet on the Welcome page (I wanted to put the link to Robert's marvelous Lively 101 page there, too, but more important I wanted to figure out how to do this....sorry for the dumb question)
Is there a way to flatten a morph or (equivalently) generate an image file for a morph? The specific case I'm thinking of is where one builds up a complex image from lots of submorphs, but once done doesn't want to manipulate the submorphs anymore...just bake the thing in place.
t***@gmail.com
2014-05-26 07:39:28 UTC
Permalink
Only just realized that Robert put a module in for 3 some time ago: https://github.com/LivelyKernel/LivelyKernel/commit/31870348b9c1b5450294b4658fef142c44fd1988


It seems you should be able to just use lively.morphic.Preview.renderMorphToNewImage(morph, {}, callback)








From: Tim Felgentreff
Sent: ‎Monday‎, ‎May‎ ‎26‎, ‎2014 ‎9‎:‎27‎ ‎AM
To: Rick McGeer, lively-***@hpi.uni-potsdam.de





Hi




Re 1: I think the functions on the world may just not be serialized usually, but it works for me if you do

$world.addScript(function onFocus(evt) {
alertOK("World focus")
if (!this.isFocusable()) { this.blur(); return };
lively.morphic.Morph.prototype._focusedMorph = this;
})





Re 2: The Shortcuts documentation says you can add links with CMD+K




Re 3: I did that once for PartsBin screenshots. This issue describes how it can be done: https://github.com/LivelyKernel/LivelyKernel/issues/248




Hope that helps,

Tim






From: Rick McGeer
Sent: ‎Monday‎, ‎May‎ ‎26‎, ‎2014 ‎3‎:‎29‎ ‎AM
To: lively-***@hpi.uni-potsdam.de





I'm having this odd behavior where $world.onFocus() is getting overwritten on a $world.saveWorld(). Specifically, I set $world.onFocus to a function which assigns the focus to a specific morph on the page ($world.get('2048Board').get('Board').focus()). This works fine, and when I click away from the tab and back to it the focus is assigned correctly. I can also look at $world.onFocus and see it's the correct function. However, after I do a $world.saveWorld() and then reload the page, I get the default $world.onFocus method, not the one I wrote. Is this a bug, or is there something I'm doing wrong?
Is there a preferred way of doing hyperlinks? I can think of at least two, and I'm sure that there are more. The two I've thought of are to use an HTMLWrapperMorph, and to attach an onMouseDown event, but I guarantee there's a third way, and the third way is better. I know there's a third way because I've looked at the source for the welcome page, and the hyperlinks are in text morphs, which turn into <span>s in the HTML source, and the links themselves are <uri> tags in the span. My problem is I don't know how to create this using Morphic (it may be I am just slow today). The hell of it is, I knew how to do it once, because I put the link to Lively Cheat Sheet on the Welcome page (I wanted to put the link to Robert's marvelous Lively 101 page there, too, but more important I wanted to figure out how to do this....sorry for the dumb question)
Is there a way to flatten a morph or (equivalently) generate an image file for a morph? The specific case I'm thinking of is where one builds up a complex image from lots of submorphs, but once done doesn't want to manipulate the submorphs anymore...just bake the thing in place.
Rick McGeer
2014-05-27 01:22:45 UTC
Permalink
Tim,
Many thanks.

-- Rick


On Mon, May 26, 2014 at 12:39 AM, <***@gmail.com> wrote:

> Only just realized that Robert put a module in for 3 some time ago:
> https://github.com/LivelyKernel/LivelyKernel/commit/31870348b9c1b5450294b4658fef142c44fd1988
>
> It seems you should be able to just use
> lively.morphic.Preview.renderMorphToNewImage(morph, {}, callback)
>
>
> *From:* Tim Felgentreff <***@gmail.com>
> *Sent:* ‎Monday‎, ‎May‎ ‎26‎, ‎2014 ‎9‎:‎27‎ ‎AM
> *To:* Rick McGeer <***@gmail.com>,
> lively-***@hpi.uni-potsdam.de
>
> Hi
>
> Re 1: I think the functions on the world may just not be serialized
> usually, but it works for me if you do
> $world.addScript(function onFocus(evt) {
> alertOK("World focus")
> if (!this.isFocusable()) { this.blur(); return };
> lively.morphic.Morph.prototype._focusedMorph = this;
> })
>
> Re 2: The Shortcuts documentation says you can add links with CMD+K
>
> Re 3: I did that once for PartsBin screenshots. This issue describes how
> it can be done: https://github.com/LivelyKernel/LivelyKernel/issues/248
>
> Hope that helps,
> Tim
>
> *From:* Rick McGeer <***@gmail.com>
> *Sent:* ‎Monday‎, ‎May‎ ‎26‎, ‎2014 ‎3‎:‎29‎ ‎AM
> *To:* lively-***@hpi.uni-potsdam.de
>
>
> 1. I'm having this odd behavior where $world.onFocus() is getting
> overwritten on a $world.saveWorld(). Specifically, I set $world.onFocus to
> a function which assigns the focus to a specific morph on the page
> ($world.get('2048Board').get('Board').focus()). This works fine, and when
> I click away from the tab and back to it the focus is assigned correctly.
> I can also look at $world.onFocus and see it's the correct function.
> However, after I do a $world.saveWorld() and then reload the page, I get
> the default $world.onFocus method, not the one I wrote. Is this a bug, or
> is there something I'm doing wrong?
> 2. Is there a preferred way of doing hyperlinks? I can think of at
> least two, and I'm sure that there are more. The two I've thought of are
> to use an HTMLWrapperMorph, and to attach an onMouseDown event, but I
> guarantee there's a third way, and the third way is better. I know there's
> a third way because I've looked at the source for the welcome page, and the
> hyperlinks are in text morphs, which turn into <span>s in the HTML source,
> and the links themselves are <uri> tags in the span. My problem is I don't
> know how to create this using Morphic (it may be I am just slow today).
> The hell of it is, I knew how to do it once, because I put the link to
> Lively Cheat Sheet on the Welcome page (I wanted to put the link to
> Robert's marvelous Lively 101 page there, too, but more important I wanted
> to figure out how to do this....sorry for the dumb question)
> 3. Is there a way to flatten a morph or (equivalently) generate an
> image file for a morph? The specific case I'm thinking of is where one
> builds up a complex image from lots of submorphs, but once done doesn't
> want to manipulate the submorphs anymore...just bake the thing in place.
>
>
Loading...