mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -16,3 +16,10 @@
|
||||
background: #9dff9d;
|
||||
opacity: .3;
|
||||
}
|
||||
|
||||
.editor .hidden-input {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user