[racket] text-field% receiving characters it shouldn't receive

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed May 4 08:32:03 EDT 2011

At Wed, 04 May 2011 11:00:19 +0100, Erich Rast wrote:
> I've got a problem with a GUI app in which a text-field% is on top of a
> frame% and a list-box% below it. 
> 1.) When the text-field has the keyboard focus, it receives characters
> of menu shortcuts, e.g. if I press ctl-n for new document, the menu
> callback is executed correctly but the text-field will contain an "n"
> afterwards. How can I prevent this? Is this a bug?

As you suspect, I think it's probably due to your `on-subwindow-char'

Does your override call the `super' method and return #t when the
`super' call returns #t?

> 2.) What is the correct way to ensure that up and down arrow keys are
> sent to the list-box, even if the text-field has the keyboard focus? 
> Right now, I've overriden on-subwindow-char of the parent frame% but I
> had to implement the list-box scrolling myself which seems a bit like a
> hack to me. Is it possible that I inadvertantly caused problem 1 by
> this? But then, how do you "transfer" chars from widget to widget?

I think `on-subwidow-char' is the right approach.

> Feature request: In the list-box it would be nice to have two methods:
> scroll-selection-down [delta 1] 
> scroll-selection-up [delta 1]
> where the delta is the number of lines to scroll. 

Added to my "to do" list.

Posted on the users mailing list.