mirror of
https://github.com/ACINQ/eclair.git
synced 2024-11-20 10:39:19 +01:00
Ignored ENTER and TAB in send payment textarea
This commit is contained in:
parent
1c18a5b819
commit
729fdf7df5
@ -25,8 +25,6 @@
|
||||
GridPane.valignment="TOP"/>
|
||||
<TextArea fx:id="paymentRequest" minHeight="150.0" prefHeight="150.0" styleClass="ta" wrapText="true"
|
||||
GridPane.columnSpan="2" GridPane.rowIndex="1" GridPane.vgrow="ALWAYS"/>
|
||||
<Button fx:id="handleSend" defaultButton="true" mnemonicParsing="false" onAction="#handleSend" text="Send"
|
||||
GridPane.rowIndex="7"/>
|
||||
<Label fx:id="paymentRequestError" opacity="0.0" text="Generic Invalid Payment Request"
|
||||
GridPane.columnSpan="2" GridPane.rowIndex="2">
|
||||
<styleClass>
|
||||
@ -37,10 +35,12 @@
|
||||
<Label styleClass="text-muted" text="Amount (mSat)" GridPane.halignment="RIGHT" GridPane.rowIndex="3"/>
|
||||
<Separator GridPane.columnSpan="2" GridPane.rowIndex="6"/>
|
||||
<Label styleClass="text-muted" text="Node Id" GridPane.halignment="RIGHT" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="amountField" editable="false" styleClass="noteditable" text="0" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="nodeIdField" editable="false" styleClass="noteditable" text="N/A" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="hashField" editable="false" styleClass="noteditable" text="N/A" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
<TextField fx:id="amountField" focusTraversable="false" editable="false" styleClass="noteditable" text="0" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="nodeIdField" focusTraversable="false" editable="false" styleClass="noteditable" text="N/A" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
<TextField fx:id="hashField" focusTraversable="false" editable="false" styleClass="noteditable" text="N/A" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
<Label styleClass="text-muted" text="hash" GridPane.halignment="RIGHT" GridPane.rowIndex="5"/>
|
||||
<Button fx:id="sendButton" defaultButton="true" mnemonicParsing="false" onAction="#handleSend" text="Send"
|
||||
GridPane.rowIndex="7"/>
|
||||
<Button cancelButton="true" mnemonicParsing="false" onAction="#handleClose" styleClass="cancel" text="Cancel"
|
||||
GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="7"/>
|
||||
</children>
|
||||
|
@ -1,9 +1,11 @@
|
||||
package fr.acinq.eclair.gui.controllers
|
||||
|
||||
import javafx.beans.value.{ChangeListener, ObservableValue}
|
||||
import javafx.event.ActionEvent
|
||||
import javafx.event.{ActionEvent, EventHandler}
|
||||
import javafx.fxml.FXML
|
||||
import javafx.scene.control.{Label, TextArea, TextField}
|
||||
import javafx.scene.control.{Button, Label, TextArea, TextField}
|
||||
import javafx.scene.input.KeyCode.{ENTER, TAB}
|
||||
import javafx.scene.input.KeyEvent
|
||||
import javafx.stage.Stage
|
||||
|
||||
import fr.acinq.eclair.Setup
|
||||
@ -22,11 +24,26 @@ class SendPaymentController(val handlers: Handlers, val stage: Stage, val setup:
|
||||
@FXML var nodeIdField: TextField = _
|
||||
@FXML var amountField: TextField = _
|
||||
@FXML var hashField: TextField = _
|
||||
@FXML var sendButton: Button = _
|
||||
|
||||
@FXML def initialize(): Unit = {
|
||||
|
||||
// ENTER or TAB events in the paymentRequest textarea insted fire or focus sendButton
|
||||
paymentRequest.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler[KeyEvent]() {
|
||||
def handle(event: KeyEvent) = {
|
||||
val parent = paymentRequest.getParent()
|
||||
event.getCode match {
|
||||
case ENTER =>
|
||||
sendButton.fire
|
||||
event.consume
|
||||
case TAB =>
|
||||
sendButton.requestFocus()
|
||||
event.consume
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
})
|
||||
paymentRequest.textProperty().addListener(new ChangeListener[String] {
|
||||
def changed(observable: ObservableValue[_ <: String], oldValue: String, newValue: String): Unit = {
|
||||
def changed(observable: ObservableValue[_ <: String], oldValue: String, newValue: String) = {
|
||||
if (GUIValidators.validate(paymentRequest.getText, paymentRequestError, "Please use a valid payment request", GUIValidators.paymentRequestRegex)) {
|
||||
val Array(nodeId, amount, hash) = paymentRequest.getText.split(":")
|
||||
amountField.setText(amount)
|
||||
@ -41,7 +58,7 @@ class SendPaymentController(val handlers: Handlers, val stage: Stage, val setup:
|
||||
})
|
||||
}
|
||||
|
||||
@FXML def handleSend(event: ActionEvent): Unit = {
|
||||
@FXML def handleSend(event: ActionEvent) = {
|
||||
if (GUIValidators.validate(paymentRequest.getText, paymentRequestError, "Please use a valid payment request", GUIValidators.paymentRequestRegex)) {
|
||||
val Array(nodeId, amount, hash) = paymentRequest.getText.split(":")
|
||||
if (GUIValidators.validate(amount, paymentRequestError, "Amount must be numeric", GUIValidators.amountRegex)
|
||||
@ -53,7 +70,7 @@ class SendPaymentController(val handlers: Handlers, val stage: Stage, val setup:
|
||||
}
|
||||
}
|
||||
|
||||
@FXML def handleClose(event: ActionEvent): Unit = {
|
||||
@FXML def handleClose(event: ActionEvent) = {
|
||||
stage.close()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user