Mercurial > cgi-bin > hgweb.cgi > ClipMan
changeset 38:08eaae2aaf76
Stop dialog resizing, fix detection of bad font sizes.
author | David Barts <n5jrn@me.com> |
---|---|
date | Thu, 30 Jan 2020 22:06:37 -0800 |
parents | 9890445e4cc4 |
children | 2a5808156f99 |
files | src/name/blackcap/clipman/CoerceDialog.kt src/name/blackcap/clipman/SearchDialog.kt |
diffstat | 2 files changed, 18 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/name/blackcap/clipman/CoerceDialog.kt Thu Jan 30 21:03:56 2020 -0800 +++ b/src/name/blackcap/clipman/CoerceDialog.kt Thu Jan 30 22:06:37 2020 -0800 @@ -42,8 +42,6 @@ it.selectedIndex = DSIZEI it.alignmentX = JComboBox.LEFT_ALIGNMENT it.setEditable(true) - it.actionCommand = "Size" - it.addActionListener(this) } val pSize: Float get() { @@ -65,8 +63,6 @@ it.selectedIndex = DSIZEI it.alignmentX = JComboBox.LEFT_ALIGNMENT it.setEditable(true) - it.actionCommand = "Size" - it.addActionListener(this) } val mSize: Float get() { @@ -148,17 +144,11 @@ } rootPane.setDefaultButton(_coerce) pack() + setResizable(false) } override fun actionPerformed(e: ActionEvent) { when (e.actionCommand) { - "Size" -> { - val source = e.source as? JComboBox<Float> - if (source != null && (source.selectedItem as Float) < 1.0f) { - Toolkit.getDefaultToolkit().beep() - source.selectedIndex = DSIZEI - } - } "Coerce" -> { setVisible(false) coerce() @@ -193,6 +183,9 @@ "Error", JOptionPane.ERROR_MESSAGE) } else { + if (badSize(_pSize, "proportionally-spaced") || badSize(_mSize, "monospaced")) { + return + } PasteboardItem.write( PasteboardItem.HTML( plain, @@ -202,6 +195,19 @@ } } + private fun badSize(control: JComboBox<Float>, fontType: String): Boolean { + val size = control.selectedItem as? Float + if (size == null || size < 1.0f) { + JOptionPane.showMessageDialog(frame.v, + "Invalid ${fontType} font size.", + "Error", + JOptionPane.ERROR_MESSAGE) + control.selectedIndex = DSIZEI + return true + } + return false + } + private fun getFontIndex(font: String): Int { val found = FONTS.indexOf(font) if (found < 0) {