@@ -198,29 +198,18 @@ object GraphEditorInput {
198198
199199 private fun handleTextMode (): Boolean {
200200 if (! state.inTextMode) return false
201+ if (! textBox.isActive) {
202+ saveAndExitTextMode()
203+ return true
204+ }
201205 textBox.handle()
202206 return true
203207 }
204208
205209 private fun handleExit (): Boolean {
206210 if (! config.exitKey.isKeyClicked()) return false
207211 if (state.inTextMode) {
208- val newText = textBox.finalText().ifEmpty { null }
209- val activeNode = state.activeNode
210-
211- if (activeNode != null && activeNode.name != newText) {
212- GraphEditorHistory .save(" renamed node" )
213- activeNode.name = newText
214- }
215-
216- state.inTextMode = false
217- GraphEditor .feedBackInTutorial(" Exited Text Mode." )
218- activeNode?.let {
219- GraphEditorNodeOperations .handleNameShortcut(it.name)?.let { (tag, name) ->
220- it.tags.add(tag)
221- it.name = name
222- }
223- }
212+ saveAndExitTextMode()
224213 return true
225214 }
226215 if (state.inEditMode) {
@@ -233,6 +222,25 @@ object GraphEditorInput {
233222 return true
234223 }
235224
225+ private fun saveAndExitTextMode () {
226+ val newText = textBox.finalText().ifEmpty { null }
227+ val activeNode = state.activeNode
228+
229+ if (activeNode != null && activeNode.name != newText) {
230+ GraphEditorHistory .save(" renamed node" )
231+ activeNode.name = newText
232+ }
233+
234+ state.inTextMode = false
235+ GraphEditor .feedBackInTutorial(" Exited Text Mode." )
236+ activeNode?.let {
237+ GraphEditorNodeOperations .handleNameShortcut(it.name)?.let { (tag, name) ->
238+ it.tags.add(tag)
239+ it.name = name
240+ }
241+ }
242+ }
243+
236244 private fun testDijkstra () {
237245 val savedCurrentPos = state.closestNode?.position ? : return
238246 val savedActivePos = state.activeNode?.position ? : return
0 commit comments