Commit ca9440d3 authored by ryoii's avatar ryoii

graphic command input

parent b30246cd
......@@ -28,6 +28,8 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
MiraiConsole.CommandListener.commandChannel.send("/login $qq $psd")
}
suspend fun sendCommand(command: String) = MiraiConsole.CommandListener.commandChannel.send(command)
override fun pushLog(identity: Long, message: String) = Platform.runLater {
when (identity) {
0L -> mainLog.add(message)
......
......@@ -5,6 +5,8 @@ import javafx.collections.ObservableList
import javafx.scene.control.Tab
import javafx.scene.control.TabPane
import javafx.scene.image.Image
import javafx.scene.input.KeyCode
import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.model.BotModel
import net.mamoe.mirai.console.graphical.util.jfxListView
......@@ -52,6 +54,17 @@ class PrimaryView : View() {
}
}
}
// command input
textfield {
setOnKeyPressed {
if (it.code == KeyCode.ENTER) {
runAsync {
runBlocking { controller.sendCommand(text) }
}.ui { text = "" }
}
}
}
}
center = jfxTabPane {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment