mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
cursor over right is workign but not the left
This commit is contained in:
@@ -114,6 +114,23 @@ class UIItemTextLineInput(
|
|||||||
|
|
||||||
private var imeOn = false
|
private var imeOn = false
|
||||||
|
|
||||||
|
private fun forceLitCursor() {
|
||||||
|
cursorBlinkCounter = 0f
|
||||||
|
cursorOn = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun tryCursorBack() {
|
||||||
|
if (cursorDrawX > fbo.width) {
|
||||||
|
val d = cursorDrawX - fbo.width
|
||||||
|
cursorDrawScroll = d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private fun tryCursorForward() {
|
||||||
|
if (cursorDrawX - cursorDrawScroll < 0) {
|
||||||
|
cursorDrawScroll -= cursorDrawX
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
super.update(delta)
|
super.update(delta)
|
||||||
val mouseDown = Terrarum.mouseDown
|
val mouseDown = Terrarum.mouseDown
|
||||||
@@ -128,9 +145,11 @@ class UIItemTextLineInput(
|
|||||||
if (isActive) {
|
if (isActive) {
|
||||||
IngameController.withKeyboardEvent { (_, char, _, keycodes) ->
|
IngameController.withKeyboardEvent { (_, char, _, keycodes) ->
|
||||||
fboUpdateLatch = true
|
fboUpdateLatch = true
|
||||||
|
forceLitCursor()
|
||||||
|
|
||||||
if (keycodes.contains(Input.Keys.V) && (keycodes.contains(Input.Keys.CONTROL_LEFT) || keycodes.contains(Input.Keys.CONTROL_RIGHT))) {
|
if (keycodes.contains(Input.Keys.V) && (keycodes.contains(Input.Keys.CONTROL_LEFT) || keycodes.contains(Input.Keys.CONTROL_RIGHT))) {
|
||||||
paste()
|
paste()
|
||||||
|
tryCursorBack()
|
||||||
}
|
}
|
||||||
else if (keycodes.contains(Input.Keys.C) && (keycodes.contains(Input.Keys.CONTROL_LEFT) || keycodes.contains(Input.Keys.CONTROL_RIGHT))) {
|
else if (keycodes.contains(Input.Keys.C) && (keycodes.contains(Input.Keys.CONTROL_LEFT) || keycodes.contains(Input.Keys.CONTROL_RIGHT))) {
|
||||||
copyToClipboard()
|
copyToClipboard()
|
||||||
@@ -139,15 +158,17 @@ class UIItemTextLineInput(
|
|||||||
cursorX -= 1
|
cursorX -= 1
|
||||||
textbuf.removeAt(cursorX)
|
textbuf.removeAt(cursorX)
|
||||||
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
||||||
|
tryCursorForward()
|
||||||
}
|
}
|
||||||
else if (cursorX > 0 && keycodes.contains(Input.Keys.LEFT)) {
|
else if (cursorX > 0 && keycodes.contains(Input.Keys.LEFT)) {
|
||||||
cursorX -= 1
|
cursorX -= 1
|
||||||
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
||||||
if (cursorDrawX < 0) cursorDrawX = 0
|
tryCursorForward()
|
||||||
}
|
}
|
||||||
else if (cursorX < textbuf.size && keycodes.contains(Input.Keys.RIGHT)) {
|
else if (cursorX < textbuf.size && keycodes.contains(Input.Keys.RIGHT)) {
|
||||||
cursorX += 1
|
cursorX += 1
|
||||||
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
||||||
|
tryCursorBack()
|
||||||
}
|
}
|
||||||
// accept:
|
// accept:
|
||||||
// - literal "<"
|
// - literal "<"
|
||||||
@@ -160,8 +181,13 @@ class UIItemTextLineInput(
|
|||||||
|
|
||||||
cursorX += codepoints.size
|
cursorX += codepoints.size
|
||||||
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
||||||
|
|
||||||
|
tryCursorBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't put innards of tryCursorBack/Forward here -- you absolutely don't want that behaviour
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textbuf.size == 0) {
|
if (textbuf.size == 0) {
|
||||||
@@ -211,6 +237,8 @@ class UIItemTextLineInput(
|
|||||||
cursorX += actuallyInserted.size
|
cursorX += actuallyInserted.size
|
||||||
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
cursorDrawX = App.fontGame.getWidth(textbuf.subList(0, cursorX))
|
||||||
|
|
||||||
|
tryCursorBack()
|
||||||
|
|
||||||
fboUpdateLatch = true
|
fboUpdateLatch = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user