mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-09 04:42:27 +08:00
graphic command input
This commit is contained in:
parent
b30246cda1
commit
ca9440d3e3
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user