Skip to content

Commit

Permalink
fix(gtk): prevent duplicate address on enter signal in create modal (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja7ad authored Nov 10, 2024
1 parent ca9820b commit ab135bc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/gtk/dialog_wallet_create_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main
import (
_ "embed"

"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/gtk"
"github.com/pactus-project/pactus/crypto"
)
Expand All @@ -26,10 +27,23 @@ func createAddress(wdgWallet *widgetWallet) {

addressTypeCombo.SetActive(0)

getButtonObj(builder, "id_button_ok").SetImage(OkIcon())
okBtn := getButtonObj(builder, "id_button_ok")
okBtn.SetImage(OkIcon())

getButtonObj(builder, "id_button_cancel").SetImage(CancelIcon())

dlg.Connect("key-press-event", func(_ *gtk.Dialog, event *gdk.Event) {
keyEvent := &gdk.EventKey{Event: event}
// Check if the Enter key was pressed
if keyEvent.KeyVal() == gdk.KEY_Return || keyEvent.KeyVal() == gdk.KEY_KP_Enter {
// Prevent Enter from triggering default behavior twice
_, _ = okBtn.Emit("clicked")
}
})

onOk := func() {
okBtn.SetSensitive(false)

walletAddressLabel, err := addressLabel.GetText()
fatalErrorCheck(err)

Expand All @@ -51,6 +65,7 @@ func createAddress(wdgWallet *widgetWallet) {
}

if err != nil {
okBtn.SetSensitive(true)
showError(err)

return
Expand Down

0 comments on commit ab135bc

Please sign in to comment.