World lastKeystroke and openInWorld: aPasteUpMorph

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

World lastKeystroke and openInWorld: aPasteUpMorph

Markus Schlager-2
Hi,

I'm using pharo to teach smalltalk as first 'real' programming language at
school. With older versions of pharo I was glad that my pupils could track
keystrokes so easily by evaluating

  World lastKeystroke.

With Pharo3.0/4.0 this only returns '<down>' independently of any keys I'm
typing.

  f := PasteUpMorph new openInWorld.
  f takeKeyBoardFocus.
  f lastKeystroke.

Is returning the empty string.

Hence, my question: Is lastKeystroke broken, or how is it meant to be used
now?

Second problem: In older versions of pharo this would work:

  f := PasteUpMorph new openInWorld.
  b := EllipseMorph new.
  b openInWorld: f.

But with Pharo 3.0/4.0 the last line raises an error:

  MessageNotUnderstood: PasteUpMorph>>startSteppingSubmorphsOf

With

  f := WorldMorph new openInWorld.
  b := EllipseMorph new.
  b openInWorld: f.

pharo freezes.

So: How is openInWorld: meant to be used?

Markus


Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

jfabry
Hi Markus,

this is probably not how it should be done, but to get the last keystroke I have been doing the following:

World activeHand instVarNamed: #lastKeyScanCode

If you find a cleaner way I’d be grateful if you can share it.

> On Jun 10, 2015, at 18:50, Markus Schlager <[hidden email]> wrote:
>
> Hi,
>
> I'm using pharo to teach smalltalk as first 'real' programming language at school. With older versions of pharo I was glad that my pupils could track keystrokes so easily by evaluating
>
> World lastKeystroke.
>
> With Pharo3.0/4.0 this only returns '<down>' independently of any keys I'm typing.
>
> f := PasteUpMorph new openInWorld.
> f takeKeyBoardFocus.
> f lastKeystroke.
>
> Is returning the empty string.
>
> Hence, my question: Is lastKeystroke broken, or how is it meant to be used now?
>
> Second problem: In older versions of pharo this would work:
>
> f := PasteUpMorph new openInWorld.
> b := EllipseMorph new.
> b openInWorld: f.
>
> But with Pharo 3.0/4.0 the last line raises an error:
>
> MessageNotUnderstood: PasteUpMorph>>startSteppingSubmorphsOf
>
> With
>
> f := WorldMorph new openInWorld.
> b := EllipseMorph new.
> b openInWorld: f.
>
> pharo freezes.
>
> So: How is openInWorld: meant to be used?
>
> Markus
>
>
>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

Pharo Smalltalk Users mailing list
In reply to this post by Markus Schlager-2
Hello Markus,


> With older versions of pharo I was glad that my pupils could track keystrokes so easily by evaluating
>
> World lastKeystroke.
>
> With Pharo3.0/4.0 this only returns '<down>' independently of any keys I'm typing.
>
> f := PasteUpMorph new openInWorld.
> f takeKeyBoardFocus.
> f lastKeystroke.
>
> Is returning the empty string.

this lastKeystroke suff seems broken
please, open an issue

>
> Hence, my question: Is lastKeystroke broken, or how is it meant to be used now?
>
> Second problem: In older versions of pharo this would work:
>
> f := PasteUpMorph new openInWorld.
> b := EllipseMorph new.
> b openInWorld: f.
>
> But with Pharo 3.0/4.0 the last line raises an error:
>
> MessageNotUnderstood: PasteUpMorph>>startSteppingSubmorphsOf

also broken
another issue to open :)

>
> With
>
> f := WorldMorph new openInWorld.
> b := EllipseMorph new.
> b openInWorld: f.
>
> pharo freezes.

Yes, I dont think that you can open a world in the root world.

Cheers
Alain

>
> So: How is openInWorld: meant to be used?
>
> Markus
>
>


Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

Pharo Smalltalk Users mailing list
In reply to this post by Markus Schlager-2

>
>>
>> Hence, my question: Is lastKeystroke broken, or how is it meant to be used now?
>>
>> Second problem: In older versions of pharo this would work:
>>
>> f := PasteUpMorph new openInWorld.
>> b := EllipseMorph new.
>> b openInWorld: f.
>>
>> But with Pharo 3.0/4.0 the last line raises an error:
>>
>> MessageNotUnderstood: PasteUpMorph>>startSteppingSubmorphsOf
>
> also broken
> another issue to open :)

Quick fix to make it work:
just move startSteppingSubmorphsOf: from WorldMorph to PasteUpMorph.

Cheers
Alain


Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

Markus Schlager-2
In reply to this post by jfabry
Hi Johan,

On Wed, 10 Jun 2015, Johan Fabry wrote:

> this is probably not how it should be done, but to get the last keystroke I have been doing the following:
>
> World activeHand instVarNamed: #lastKeyScanCode
>
> If you find a cleaner way I’d be grateful if you can share it.

The solution proposed by PharoByExample, p. 228 is to override
Morph>>handleKeystroke:

---8X---------------------------------
Morph subclass: #MyMorph

MyMorph>>handleKeystroke: anEvent
  | keyValue keyName |
  keyValue := anEvent keyValue. "integer"
  keyName := anEvent keyString. "string like '<up>' or 'a'"
  ...

m := MyMorph new.
m takeKeyboardFocus.
---8X---------------------------------

Markus
Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

Markus Schlager-2
In reply to this post by Pharo Smalltalk Users mailing list
issues opened

Markus

Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

Nicolai Hess


2015-06-11 10:58 GMT+02:00 Markus Schlager <[hidden email]>:
issues opened

I added a fix for the broken lastkeystroke,but this will only work for the ActiveWorld/PasteUpMorph, not for any other
PasteUpMorph.

With the split of PasteUpMorph in PasteUpMorph and WorldMorph, and the change of keystroke handling (KMDispatcher), there is more to do to make this
fully work again - but I don't want to reintroduce the old keyevent
handling just to make this work again.

I would like to remove all the keystroke handling from PasteUpMorph/WorldMorph
and use only KMDispatcher.

Maybe there is another(new) way to make this "lastKeystroke"-demo?
You can open  a transcript and enable the KMLog
(KMLog setDebug. Transcript open)
It will log all(!) keyevents and print the matching keymapping actions.
Or something like this:
|m|
m
:= Morph new.
m openInWorld
.
m takeKeyboardFocus
.
m on
:($r ctrl) do:[ m color:Color red].
m on
:($g ctrl) do:[ m color:Color green].
m on
:($b ctrl) do:[ m color:Color blue].

This will open a morph that changes its color on ctrl+r/g/b
So, maybe we can remove the whole "lastKeystroke" handling and make demos/examples
like the above one?



 

Markus


Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

HilaireFernandes
In reply to this post by Markus Schlager-2
Le 10/06/2015 23:50, Markus Schlager a écrit :
>
> I'm using pharo to teach smalltalk as first 'real' programming
> language at school. With older versions of pharo I was glad that my
> pupils could track keystrokes so easily by evaluating
Off topic, but I am curious as a teacher: how old the pupils you are
teaching to?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu
http://google.com/+DrgeoEu



Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

Markus Schlager-2
On Tue, 16 Jun 2015, Hilaire wrote:

> Off topic, but I am curious as a teacher: how old the pupils you are
> teaching to?

I use Etoys or Scratch in grade 7 (age about 12 years) and Smalltalk in
grade 10 (age about 15/16 years). They are attending regular
"Informatik"-courses at Gymnasium, supposed to learn object-oriented
modeling and programming.

Markus

Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

stepharo
Cool
Noury has some nice exercises for starters.



Le 18/6/15 23:29, Markus Schlager a écrit :

> On Tue, 16 Jun 2015, Hilaire wrote:
>
>> Off topic, but I am curious as a teacher: how old the pupils you are
>> teaching to?
>
> I use Etoys or Scratch in grade 7 (age about 12 years) and Smalltalk
> in grade 10 (age about 15/16 years). They are attending regular
> "Informatik"-courses at Gymnasium, supposed to learn object-oriented
> modeling and programming.
>
> Markus
>
>


sujetTpSmallltalk1.pdf (222K) Download Attachment
sujet.pdf (127K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: World lastKeystroke and openInWorld: aPasteUpMorph

stepharo
In reply to this post by Markus Schlager-2
Hi markus

how can we help you?
what are the exercises that you have

- started to work on
         - Wallet something that contains coins and you should know how
much money you get
         - captchas
         - simple counter
         - (I was still lukring at the exercises of Noury)

Stef

Le 18/6/15 23:29, Markus Schlager a écrit :

> On Tue, 16 Jun 2015, Hilaire wrote:
>
>> Off topic, but I am curious as a teacher: how old the pupils you are
>> teaching to?
>
> I use Etoys or Scratch in grade 7 (age about 12 years) and Smalltalk
> in grade 10 (age about 15/16 years). They are attending regular
> "Informatik"-courses at Gymnasium, supposed to learn object-oriented
> modeling and programming.
>
> Markus
>
>