Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyPress fix #170

Closed
wants to merge 1 commit into from
Closed

KeyPress fix #170

wants to merge 1 commit into from

Conversation

baalhiverne
Copy link
Contributor

keypress now:

  • Understands key modifiers (alt ctrl shift)
  • Uses Shoes v3 naming convention
  • yields symbols when key modifiers and/or special keys

keypress now:
- Understands key modifiers (alt ctrl shift)
- Uses Shoes v3 naming convention
- yields symbols when key modifiers and/or special keys
@PragTob
Copy link
Member

PragTob commented Dec 14, 2012

Yay man! Thank you!
Will take a look at it tomorrow (too late now) and then think about testing and stuff... :-)

@ashbb
Copy link
Member

ashbb commented Dec 16, 2012

@baalhiverne I confirmed this tiny snippet with your baalhiverne:master on my Windows 7.

Shoes.app do
  keypress do |k|
    p k
  end
end

And got the following.

"a"                            #=> a
:""                            #=> Shift
"A"                            #=> Shift + a
:""                            #=> Ctrl
:"control_\u0001"              #=> Ctrl + a
:""                            #=> Alt
:alt_a                         #=> Alt + a
:""                            #=> Ctrl
:control_                      #=> Ctrl + Shift
:"control_shift_\u0001"        #=> Ctrl + Shift + a
:"\n"                          #=> Ebter
:delete                        #=> Delete
:""                            #=> Shift
"!"                            #=> Shift + 1
:backspace                     #=> Backspce
:escape                        #=> Esc

Great work, thanks!

But if we keep compatibility with Shoes 3, keypress doesn't return anything when just only modifier keys are pressed.

@PragTob
Copy link
Member

PragTob commented Dec 16, 2012

Thanks for looking at it @ashbb so there still seems to be a problem we should fix with control + a etc. and ignoring just modifier keys.

About testing if I understand the code correctly we could just stub the argument - e in this case. so kind of like:

key = mock(:key, keyCode: 55, stateMask: WHATEVER_THE_STATE_MASK_LOOKS_LIKE)

Then call the method and see if the correct result is returned. That should be done for some major key combinations, like the ones ashbb tested - I'm happy to help you with that if you like :-)
I don't know if it'd be possible to simulate real key presses somehow... hmm maybe I'll look into that another time.

One other thing, I'm not quite sure but I think we settled with calling all methods ruby style (key_code instead of keyCode) ( @wasnotrice @ashbb can you confirm?).

Thank you very much for your work on this @baalhiverne <3
Tobi

@davorb
Copy link
Member

davorb commented Dec 29, 2012

Awesome work @baalhiverne !

Could you just change some of the methods to use snake_case, like instead of stateMask change it to state_mask and so on. That would be great! Thanks!

@ghost ghost assigned PragTob Jun 17, 2013
@PragTob
Copy link
Member

PragTob commented Jun 17, 2013

just FYI I'm working on this on my fixKeyPress Branch: https://github.com/PragTob/shoes4/tree/keypressFix

Some bugs still remain.. for now shift + left_arrow doesn't give shift_left for instance but so far I got this nicely specced out. So this is close to opening a PR and getting merge. Hope I get it done today but gotta run now.

Cheers,
Tobi

@PragTob
Copy link
Member

PragTob commented Jun 17, 2013

Work can be seen in #279 so I will close this PR here and we can move the discussion there.

@PragTob PragTob closed this Jun 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants