Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Don't catch keyboard events outside vim canvas #24

Merged
merged 5 commits into from Jan 30, 2015

Conversation

emnh
Copy link
Contributor

@emnh emnh commented Jan 30, 2015

If you want to embed vim.js on a bigger page, you need to be able to use keyboard outside vim canvas. Currently the page listens on document and uses preventDefault. This patch makes it only catch key events if last mouse down was on canvas.

I also fix one bug with IE not having console.group.

vimjs.lastMouseDownTarget = vimjs.canvas_node; // set focus on start

var ignoreKeys = function() {
var retval = (vimjs.lastMouseDownTarget !== vimjs.canvas_node);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just return !(a !== b) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I shortened it now. I was looking at some similar code where there could be a problem with undefined checks, that's why it was like that.

@emnh
Copy link
Contributor Author

emnh commented Jan 30, 2015

Ok. I made the changes you requested.

@emnh
Copy link
Contributor Author

emnh commented Jan 30, 2015

Oh, sorry, I accidentally committed everything. Wait a second.

@@ -24,7 +24,7 @@ $EM_DIR/emconfigure ./configure \
--disable-workshop \
--disable-netbeans \
--disable-sniff \
--disable-multibyte \
--enable-multibyte \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this?
How much would the size of vim.js be increased? And are the characters displayed correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this was not supposed to be committed. The size increases from 25MB to 44MB with multibyte, but the multibyte patch is not complete since it does not work yet. I shall send a different pull request for that once I am done.

@emnh
Copy link
Contributor Author

emnh commented Jan 30, 2015

Ok. That should fix it. Now contains only the keyboard fix.

@coolwanglu
Copy link
Owner

Looks good to me now. Thanks!

coolwanglu added a commit that referenced this pull request Jan 30, 2015
Don't catch keyboard events outside vim canvas
@coolwanglu coolwanglu merged commit 9bf8aea into coolwanglu:master Jan 30, 2015
@emnh emnh deleted the bugfix/keycapture branch January 30, 2015 13:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants