librelist archives

« back to archive

Keypress question

Keypress question

From:
Steve Klabnik
Date:
2010-11-01 @ 03:52
Hey guys-

So in a keypress block, if someone sends in a key with a modifier, you don't
get a string, you get :alt_3, for example.

Problem is, what happens when someone wants to input, for example, £, which
is alt+3 on my layout? How would I turn :alt_3 into £?

Note, Shoes handles this correctly. If you do

Shoes.app do
  edit_box
end

You can type £ all day, and it works. This happens to me with Hackety
because we do a bunch of stuff to manipulate the text, so it's a bit more
complicated.

http://github.com/hacketyhack/hacketyhack/blob/master/app/ui/editor/editor.rb#L262,
if anyone cares...


Thoughts?

-Steve

Re: [shoes] Keypress question

From:
Cecil Coupe
Date:
2010-11-01 @ 05:04
Obviously the key chords are fine for edit box/line. Don't Change them
(even if you can, don't). Those are text characters. The OS and GUI
toolkits are doing the hard work for us.

I think of Keypressed (or key released) as primarily events (arrow_down,
shift arrow_right, alt shift left_arrow) that have to be interpreted by
the given Shoes code block wants them to be. In one game, arrow-left
might be something different that in another game or app. 

If for some reason a Shoes app wants to reinvent the mulitple key->char
state machine I think adding adding a new Shoes event would be the
better way. Like 'keychar do {|c| puts c} or if if only applies to a
canvas, then a block to be passed at canvas creations. 

On Sun, 2010-10-31 at 23:52 -0400, Steve Klabnik wrote:
> Hey guys-
> 
> 
> So in a keypress block, if someone sends in a key with a modifier, you
> don't get a string, you get :alt_3, for example.
> 
> 
> Problem is, what happens when someone wants to input, for example, £,
> which is alt+3 on my layout? How would I turn :alt_3 into £?
> 
> 
> Note, Shoes handles this correctly. If you do
> 
> 
> Shoes.app do
>   edit_box
> end
> 
> 
> You can type £ all day, and it works. This happens to me with Hackety
> because we do a bunch of stuff to manipulate the text, so it's a bit
> more
> complicated. 
http://github.com/hacketyhack/hacketyhack/blob/master/app/ui/editor/editor.rb#L262
, if anyone cares...
> 
> 
> 
> 
> Thoughts?
> 
> 
> -Steve

Re: [shoes] Keypress question

From:
Steve Klabnik
Date:
2010-11-01 @ 11:35
This makes it hard to do things like autoindentation, text completion, and
other stuff, though.

Or at least, apparently I'll have to totally re-write the way that I'm doing
it...

Oh well!

Re: [shoes] Keypress question

From:
Cecil Coupe
Date:
2010-11-02 @ 03:17
Yeah, Shoes is being pushed out of its comfort zone for writing an
internationalized text editor or terminal emulator. 

On Mon, 2010-11-01 at 07:35 -0400, Steve Klabnik wrote:
> This makes it hard to do things like autoindentation, text completion,
> and other stuff, though.
> 
> 
> Or at least, apparently I'll have to totally re-write the way that I'm
> doing it...
> 
> 
> Oh well!

Re: [shoes] Keypress question

From:
Steve Klabnik
Date:
2010-11-02 @ 03:30
Yep. Good times!