[Newbies] nextSlide button as an example for accessing morphs // simple presentation
H. Hirzel
hannes.hirzel at gmail.com
Tue Mar 7 11:20:16 UTC 2017
Hello Tim
Please find another example at the bottom which illustrates the access
to morphs.
A SimpleButtonMorph embedded in a PasteUpMorph gets access to siblings
of the PasteUpMorph it is embedded in.
a simple presentation.
Regards
--Hannes
On 2/23/17, Tim Cuthbertson <ratcheer at gmail.com> wrote:
> Thank you, Hannes. That is exactly the kind of info I have been trying to
> find.
>
> Tim Cuthbertson
>
> ---------- Forwarded message ----------
> From: H. Hirzel <hannes.hirzel at gmail.com>
> Date: Wed, Feb 22, 2017 at 5:34 PM
> Subject: Re: [Newbies] Beginners Digest, Vol 123, Issue 4
> To: "A friendly place to get answers to even the most basic questions about
> Squeak." <beginners at lists.squeakfoundation.org>
> Cc: ratcheer at gmail.com
>
>
> Assuming you have named your instances of TextMorph and embedded them
> in the PasteUpMorph so that they are in the 'submorphs' collection of
> the PasteUpMorph
>
> you may access them by name from the PasteUpMorph with
>
>
......
| buttonActionBlock createButtonBlock createSlideBlock content1Block
slideCollection |
buttonActionBlock := [:button | button owner submorphAfter isNil
ifTrue: [button owner owner submorphs first show]
ifFalse: [button owner hide.
button owner submorphAfter show]].
createButtonBlock := [| b |
b := SimpleButtonMorph new label: 'next'.
b target: buttonActionBlock.
b actionSelector: #value:.
b
arguments: (Array with: b)].
createSlideBlock := [:aColor :aString |
| p |
p := PasteUpMorph new extent: 640 @ 480;
color: aColor.
p
addMorph: (createButtonBlock value openInWorld position: 600 @ 450).
p setProperty: #isSlide toValue: true.
p addMorph: (TextMorph new contentsWrapped: aString;
fontName: 'BitstreamVeraSans' pointSize: 24;
extent: 500 @ 50;
position: 20 @ 20).
].
content1Block := [:pm |
pm addMorph: (RectangleMorph new extent: 50 @ 50;
position: 20 @ 120;
color: Color red).
pm addMorph: (RectangleMorph new extent: 50 @ 50;
position: 20 @ 180;
color: Color blue).
pm addMorph: (RectangleMorph new extent: 50 @ 50;
position: 20 @ 240;
color: Color white).
pm addMorph: (RectangleMorph new extent: 50 @ 50;
position: 20 @ 300;
color: Color black).
pm addMorph: (TextMorph new contentsWrapped: '4 instances of PasteUpMorph';
fontName: 'BitstreamVeraSans' pointSize: 24;
extent: 500 @ 50;
position: 80 @ 120)].
slideCollection := Morph new extent: 640 @ 480.
slideCollection setProperty: #isSlideCollection toValue: true.
slideCollection
addMorphBack: (content1Block
value: (createSlideBlock value: Color yellow value: 'Simple
presentation - slide 1')).
slideCollection
addMorphBack: (createSlideBlock value: Color green value: 'slide 2').
slideCollection
addMorphBack: (createSlideBlock value: Color gray value: 'slide 3').
slideCollection
addMorphBack: (createSlideBlock value: Color blue value: 'slide 4').
slideCollection openInWorld; position: 30 @ 30
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SimplePresentation_done_in_code_with_PasteUpMorphs_Screenshot_2017-03-07.png
Type: image/png
Size: 35408 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20170307/070f742a/attachment-0001.png>
More information about the Beginners
mailing list