[Pharo-project] [Event related] Character vs Keys

8 views
Skip to first unread message

Guillermo Polito

unread,
Jan 24, 2012, 2:20:43 PM1/24/12
to Pharo Development
Hi!

While playing (again) to add Function keys support, reading documentation of how keyboard handling works on our vm and other platforms:

.Net: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx
Javascript: http://www.quirksmode.org/js/keys.html

And a quick explanation of Igor of how our vm works: http://lists.squeakfoundation.org/pipermail/vm-dev/2011-November/009661.html


What puzzles me is some of the following:

- Keypress event should only be raised to send keystrokes having a character representation.
- but some keystrokes with no character representation are taken as keypresses! (arrowup, arrowdown, esc...) (and so, used to handle events instead of doing it on keydown)
- the strokes above should be only raised in keydowns IMHO.
- more on, we have in Character class representations for those non characters :P which is funny because they are not characters.

And everything works, and fits in a kind of strange way :).

Now, rearranging this to follow those conventions means:
- reify Keys (vs Characters).  So we can model modifier keys, function keys, arrow keys, independent from Characters.
- Keys (non-characters) should only be raised as single events on keydown.
- and the worse part is to fix all the hardcoded shortcuts messed everywhere in the image.

Any thoughts on this?

Thanks!
Guille

Johan Fabry

unread,
Jan 24, 2012, 2:36:40 PM1/24/12
to Pharo-...@lists.gforge.inria.fr

I am all for cleaning this up, but I'm sorry that I cannot be very constructive on this. I'd just like to confirm that keyboard handling with regard to special keypresses does not behave correctly. Try this in a workspace or transcript: hit ctrl-1 This prints 1. Same for 2 till 8. Guess what ctrl-9 does. No, it does not print 9. Try it ... 

In my opinion, ctrl-whatever should not put anything at all in the transcript window as it is not a normal keypress. Same holds for all ctrl, option, alt, command, et cetera modifier key presses, except for shift of course. 

But even so, the strange behavior of ctrl-9 does not really have a clear justification.


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

Johan Fabry   
PLEIAD Lab - Computer Science Department (DCC) - University of Chile



Stéphane Ducasse

unread,
Jan 24, 2012, 4:50:29 PM1/24/12
to Pharo-...@lists.gforge.inria.fr
I should learn more on the topic :).
But on the principle yes I want to avoid all the hardcode stuff everywhere.
Guillermo in feb we should have a coffee meeting with a group building new UI using Python (of course)
and I could ask them how they manage keystrokes. Or we can also interact with them by mail.
May be they do not have the answer.

Fernando Olivero

unread,
Jan 24, 2012, 5:54:15 PM1/24/12
to Pharo-...@lists.gforge.inria.fr
YES! the keyboard events handling is a mess that should be rethought
and simplified.

I've recently played with Cocoa, and created a windowed app, that
captures events and sends them to a pharo image via sockets. so i
learned how is done in COCOA. In Cocoa, there are 3 key events:

NSKeyDown: The user generated a character or characters by pressing a key.
NSKeyUp: The user released a key. This event is always preceded by a
NSKeyDown event.
NSFlagsChanged: The user pressed or released a modifier key, or turned
Caps Lock on or off.

"When the type of an event is NSKeyDown, the next step is typically to
get the characters generated by the key-down using the characters
method."

I think the COCOA VM, should simply forward this events to the image.
Esteban, would this be possible?

The three are enough, to preserve all the current behavior of Morphic.

In short, the VM should omit keyChar keyboard events, and start
announcing non-characters pressed or released events.


Fernando


On Tue, Jan 24, 2012 at 10:50 PM, Stéphane Ducasse
<stephane...@inria.fr> wrote:
> I should learn more on the topic :).
> But on the principle yes I want to avoid all the hardcode stuff everywhere.
> Guillermo in feb we should have a coffee meeting with a group building new UI using Python (of course)
> and I could ask them how they manage keystrokes. Or we can also interact with them by mail.
> May be they do not have the answer.
>

Esteban Lorenzano

unread,
Jan 25, 2012, 4:03:57 PM1/25/12
to Pharo-...@lists.gforge.inria.fr, fernando...@usi.ch
Hi,

yes, it should be possible, but I need to see and think a bit on the best way to implement it... maybe a week end task?

best,
Esteban

Guillermo Polito

unread,
Jan 25, 2012, 4:06:17 PM1/25/12
to Pharo-...@lists.gforge.inria.fr, fernando...@usi.ch
Does Cocoa VM send Function keys to the image? :D  How difficult is it to add?
Reply all
Reply to author
Forward
0 new messages