Adding a slot to platform classes

41 views
Skip to first unread message

Steven Marks

unread,
Jun 20, 2015, 12:04:43 PM6/20/15
to newspeak...@googlegroups.com
I am currently working on adding some basic keypress events to newspeak. So far it works, but ideally I would like to add new slots to brazil and the windows mapping class. The problem is that when I try to access the new slots through the platform object the new slots return nil.

To see this behavior add a new public slot to brazil called testSlot and set the value to a string. Trying to access that slot by calling "platform brazil testSlot" in a workspace returns nil. Initializing a new instance of brazil and then calling testSlot works as expected. Adding new classes or methods work as expected through the platform object, so it is easy to work around, but I would rather not use a workaround if possible.

So how would I go about adding slots to the platform objects?

Steven

Gilad Bracha

unread,
Jun 20, 2015, 12:34:50 PM6/20/15
to newspeak...@googlegroups.com
Hi!

A classes' factory is only run when an instance is created. When you add a slot, it gets added to all existing instances, but it gets the default value of nil, because the initialization code in the factory method isn't executed.  So you need to get a new brazil instance, which needs to be tied to the platform instance, which needs to be tied to the IDE instance you are running.

The easiest way to achieve this is to choose the "Reset Everything" menu option from the Tools menu in the toolbar at the top of the Squeak window. Best to close all your Hopscotch windows first. Then use the Tools menu again to open a new Hopscotch window via the "Newspeak Browser" option.  This will create a new IDE instance tied to a new platform instance, which will have a new brazil instance, properly initialized.

Similarly for any platform state.

Let us know how it goes. Maybe we can take it back if it's useful.

Steven Marks

unread,
Jun 20, 2015, 3:50:41 PM6/20/15
to newspeak...@googlegroups.com
Thanks for your help

I had to save and reload the image after hitting "Reset Everything" to get windows native mode to work again. But everything works fine after reloading.

I will let you know when I have something more substantial to show

Gilad Bracha

unread,
Jun 20, 2015, 6:56:07 PM6/20/15
to newspeak...@googlegroups.com, smar...@gmail.com


On Saturday, June 20, 2015 at 12:50:41 PM UTC-7, Steven Marks wrote:
Thanks for your help

I had to save and reload the image after hitting "Reset Everything" to get windows native mode to work again. But everything works fine after reloading.

That shouldn't be necessary. But that's minor.  Hope it goes well!

Steven Marks

unread,
Jun 28, 2015, 1:23:59 PM6/28/15
to newspeak...@googlegroups.com
I have successfully implemented some basic, window level, keypress events for both the windows and morphic backends. What I have so far can be found here[1]. I implemented enough for what I need at the moment, let me know if there is anything useful and I will separate it out.

I am currently working on building a hyperdocument system based on the ideas of Doug Engelbart. The current version is written in javascript, in the browser here[2]. I plan on writing the next version of this project in newspeak.

[1] https://bitbucket.org/steven_marks/hyperdocument-system-newspeak-client
[2] https://github.com/smarks159/hyperdocument-system-wiki

Gilad Bracha

unread,
Jun 28, 2015, 6:09:38 PM6/28/15
to newspeak...@googlegroups.com
Thanks Steve!

We'll take a look. Might take a while, as I'll be traveling soon.  I have a strong interest in a literate programming system for Newspeak (the samples repo has code for this in the Ampleforth class) maybe there's some overlap here.

Gilad Bracha

unread,
Jun 28, 2015, 6:22:17 PM6/28/15
to newspeak...@googlegroups.com
Actually, Ampleforth is in the main repo due to some confusion on my part.

Steven Marks

unread,
Jun 29, 2015, 1:00:37 PM6/29/15
to newspeak...@googlegroups.com
Ampleforth imports a class called BrowsingForHTML, which doesn't seem to be included in the main repo. Where can I find this class?

Gilad Bracha

unread,
Jun 29, 2015, 2:41:42 PM6/29/15
to newspeak...@googlegroups.com
In the samples repo

Gilad Bracha

unread,
Jun 29, 2015, 4:24:07 PM6/29/15
to newspeak...@googlegroups.com
Steve,

Actually, it turns out I had neglected to put it back. I put it back in the main repo now. Maybe it will move to samples in the end, we'll see.
Reply all
Reply to author
Forward
0 new messages