package com.marvinelsen.willow.ui.util

import com.marvinelsen.willow.ui.DictionaryEntryFx
import javafx.event.EventHandler
import javafx.scene.control.ContextMenu
import javafx.scene.control.MenuItem
import java.util.ResourceBundle

fun createContextMenuForEntry(entry: DictionaryEntryFx, resourceBundle: ResourceBundle) = ContextMenu().apply {
    val menuItemCopyHeadword =
        MenuItem(resourceBundle.getString("menubar.edit.copy.headword")).apply {
            onAction = EventHandler { ClipboardHelper.copyString(entry.traditionalProperty.value) }
        }

    val menuItemCopyPronunciation =
        MenuItem(resourceBundle.getString("menubar.edit.copy.pronunciation")).apply {
            onAction = EventHandler { ClipboardHelper.copyString(entry.pinyinWithToneMarksProperty.value) }
        }

    items.addAll(menuItemCopyHeadword, menuItemCopyPronunciation)
}
