[plt-scheme] clicking in an editor window

From: Prabhakar Ragde (plragde at uwaterloo.ca)
Date: Sat Oct 8 09:32:28 EDT 2005

I'm trying to create a slightly more Slideshow-like implementation of 
Kathi Fisler's exercises in creating a presentation language:

http://web.cs.wpi.edu/~cs1102/a05/Lectures/PPTLang/ppt-stage1.scm

Her implementation, which has the virtue of being completely accessible 
to beginners, simply prints the lines of the "slides" out in the 
Interactions window. I'm trying to get the lines to display in a 
separate window.

I can do this by putting up a canvas% and drawing on it, but then I have 
to keep track of the current position of the cursor and all that. 
Alternately, I can use an editor-canvas% and lock it, meaning that the 
user can't change it, and it handles all the text stuff for me. That 
works fine for writing and clearing.

But Kathi's mini-language has one more feature, which is to pause 
waiting for the user to advance the slide. In her simple implementation, 
she does this with (read). I'd like to do it with a mouse click or arrow 
key.

I can easily set a clickback for the entire text in the window so far. 
(Actually, I have another question about that, which I'll ask below.) 
But it doesn't work if I click in the parts of the window that have not 
been written on. I need to click on existing text.

Do I have to create a new class inheriting from editor% and override 
on-event in it, or is there a simpler way? That's question one.

Question two concerns the clickback. I thought that my wait-for-user 
function could just call semaphore-wait, and my clickback function could 
call semaphore-post. So I created a function mytest which writes a line, 
calls my wait-for-user function, then writes a line. When I run 
(mytest), a window comes up, the first line is written, and then I 
cannot get it to respond when I click in it; I have to hit the Stop 
button. But when I run (thread mytest), it works the way I want it to. 
Having my clickback function invoke semaphore-post within an application 
of thread does not work. My mental model of what is going on is clearly 
inadequate, and if anyone can explain this, I would be grateful.

Many thanks, and Happy Canadian Thanksgiving to all! --PR


Posted on the users mailing list.