Editor directs focus to a hidden input element.

Now we'll be able to listen for textInput events, which give us better
information about what character is being entered in the presence of
multi-keystroke compositions like alt-u,u for ü
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-24 15:27:05 -08:00
parent 18f09aad9e
commit 6af33c3337
3 changed files with 22 additions and 0 deletions

View File

@@ -207,3 +207,13 @@ describe "Editor", ->
expect(editor.cursor.position().top).toBe(2 * editor.lineHeight)
expect(editor.cursor.position().left).toBe(2 * editor.charWidth)
describe "when the editor is focused", ->
it "focuses the hidden input", ->
editor.attachToDom()
editor.focus()
expect(editor).not.toMatchSelector ':focus'
expect(editor.hiddenInput).toMatchSelector ':focus'

View File

@@ -11,6 +11,7 @@ class Editor extends Template
@div class: 'editor', tabindex: -1, =>
@div outlet: 'lines'
@subview 'cursor', Cursor.build()
@input class: 'hidden-input', outlet: 'hiddenInput'
viewProperties:
buffer: null
@@ -31,6 +32,10 @@ class Editor extends Template
@on 'move-down', => @moveDown()
@on 'move-up', => @moveUp()
@on 'focus', =>
@hiddenInput.focus()
false
@one 'attach', =>
@calculateDimensions()

View File

@@ -16,3 +16,10 @@
background: #9dff9d;
opacity: .3;
}
.editor .hidden-input {
position: fixed;
top: 0;
left: 100%;
}