From 47d53d4df8a8f36ccf04897d030d3f3cbd551345 Mon Sep 17 00:00:00 2001 From: Marvin Elsen Date: Sat, 21 Sep 2024 13:41:45 +0200 Subject: [PATCH] Add context menu to list entries --- .../com/marvinelsen/willow/ui/cells/EntryCellFactory.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/marvinelsen/willow/ui/cells/EntryCellFactory.kt b/src/main/kotlin/com/marvinelsen/willow/ui/cells/EntryCellFactory.kt index 0513a6a..6ead1d8 100644 --- a/src/main/kotlin/com/marvinelsen/willow/ui/cells/EntryCellFactory.kt +++ b/src/main/kotlin/com/marvinelsen/willow/ui/cells/EntryCellFactory.kt @@ -44,15 +44,13 @@ internal class EntryCell : ListCell() { init { text = null - if (item != null) { - contextMenu = createContextMenuForEntry(item!!) - } } override fun updateItem(entry: DictionaryEntryFx?, empty: Boolean) { super.updateItem(entry, empty) if (empty || entry == null) { graphic = null + contextMenu = null } else { labelHeadword.text = entry.traditionalProperty.value labelPronunciation.text = entry.pinyinWithToneMarksProperty.value @@ -60,6 +58,7 @@ internal class EntryCell : ListCell() { val definition = entry.definitions.joinToString(separator = " / ") { it.joinToString(separator = "; ") } labelDefinition.text = definition + contextMenu = createContextMenuForEntry(entry) graphic = root } }