Hi, I am trying to replicate the following javascript code:
-- stage.addEventListener(KeyboardEvent.KEY_DOWN, onKD); function onKD (e) 34 { 35 console.log(e.keyCode); 36 if(e.keyCode == 37) l = true; 37 if(e.keyCode == 38) u = true; 38 if(e.keyCode == 39) r = true; 39 if(e.keyCode == 40) d = true; 40 } You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout.
<zenchess@gmail.com>
|
Hi there! Thy with KeyboardEvent at: 'KEY_DOWN', I believe this should work. Cheers, You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
I tried that, and it brings up a smalltalk error: blockclosure does not understand at:
-- On Thursday, November 12, 2015 at 12:54:30 AM UTC-6, Bernat Romagosa wrote:
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout.
<zenchess@gmail.com>
|
Hmmm I see... can you share the whole project so we can tinker a little bit? 2015-11-12 23:46 GMT+01:00 Zenchess <[hidden email]>:
Bernat Romagosa.
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Jacob Wagner
BlockClosure is a Smalltalk-level object (that's the problem when JS
functions are used to contains other properties; why is KeyboardEvent a function, BTW?). What you want to access, are JS-level properties. There are three ways: 1. use low-level accessor: Foo basicAt: 'KEY_DOWN'. 2. temporarily wrap it in JS proxy: (JSObjectProxy on: Foo) at: 'KEY_DOWN'. 3. permanently remove Smalltalkiness: Smalltalk optOut: Foo, after which you can treat it as raw JS value and use Foo at: 'KEY_DOWN'. Herby P.S.: Just FYI, 3. can be reverted by Smalltalk cancelOptOut: Foo. P.P.S.: There's an ages old issue to allow underscore in identifiers: https://github.com/amber-smalltalk/amber/issues/20 Zenchess wrote: > I tried that, and it brings up a smalltalk error: blockclosure does not > understand at: > > On Thursday, November 12, 2015 at 12:54:30 AM UTC-6, Bernat Romagosa wrote: > > Hi there! > > Thy with KeyboardEvent at: 'KEY_DOWN', I believe this should work. > > Cheers, > Bernat. > > -- > You received this message because you are subscribed to the Google > Groups "amber-lang" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [hidden email] > <mailto:[hidden email]>. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |