diff --git a/addAccount.go b/addAccount.go index 23fd0ac..b5529dc 100644 --- a/addAccount.go +++ b/addAccount.go @@ -20,9 +20,10 @@ func AddAccountQuestionBox(junk *ui.Box, custom func(*ButtonMap)) *ui.Box { return newbox } -func AddAccountBox(custom func(*ButtonMap)) *ui.Box { +func AddAccountBox(aTab *GuiTabStructure) { vbox := ui.NewVerticalBox() vbox.SetPadded(true) + aTab.firstBox = vbox hboxAccount := ui.NewHorizontalBox() hboxAccount.SetPadded(true) @@ -67,13 +68,13 @@ func AddAccountBox(custom func(*ButtonMap)) *ui.Box { vboxN.SetPadded(true) vboxN.Append(ui.NewLabel("Account Nickname:"), false) - entryNick := ui.NewEntry() - entryNick.SetReadOnly(false) + aTab.EntryNick = ui.NewEntry() + aTab.EntryNick.SetReadOnly(false) - vboxN.Append(entryNick, false) + vboxN.Append(aTab.EntryNick, false) - entryNick.OnChanged(func(*ui.Entry) { - log.Println("OK. nickname =", entryNick.Text()) + aTab.EntryNick.OnChanged(func(*ui.Entry) { + log.Println("OK. nickname =", aTab.EntryNick.Text()) // Data.AccNick = entryNick.Text() }) hboxAccount.Append(vboxN, false) @@ -84,13 +85,13 @@ func AddAccountBox(custom func(*ButtonMap)) *ui.Box { vboxU.SetPadded(true) vboxU.Append(ui.NewLabel("Account Username:"), false) - entryUser := ui.NewEntry() - entryUser.SetReadOnly(false) + aTab.EntryUser = ui.NewEntry() + aTab.EntryUser.SetReadOnly(false) - vboxU.Append(entryUser, false) + vboxU.Append(aTab.EntryUser, false) - entryUser.OnChanged(func(*ui.Entry) { - log.Println("OK. username =", entryUser.Text()) + aTab.EntryUser.OnChanged(func(*ui.Entry) { + log.Println("OK. username =", aTab.EntryUser.Text()) // Data.AccUser = entryUser.Text() }) hboxAccount.Append(vboxU, false) @@ -101,13 +102,13 @@ func AddAccountBox(custom func(*ButtonMap)) *ui.Box { vboxP.SetPadded(true) vboxP.Append(ui.NewLabel("Account Password:"), false) - entryPass := ui.NewEntry() - entryPass.SetReadOnly(false) + aTab.EntryPass = ui.NewEntry() + aTab.EntryPass.SetReadOnly(false) - vboxP.Append(entryPass, false) + vboxP.Append(aTab.EntryPass, false) - entryPass.OnChanged(func(*ui.Entry) { - log.Println("OK. password =", entryPass.Text()) + aTab.EntryPass.OnChanged(func(*ui.Entry) { + log.Println("OK. password =", aTab.EntryPass.Text()) // Data.AccPass = entryPass.Text() }) hboxAccount.Append(vboxP, false) @@ -119,11 +120,9 @@ func AddAccountBox(custom func(*ButtonMap)) *ui.Box { hboxButtons.SetPadded(true) vbox.Append(hboxButtons, false) - okButton := CreateButton(nil, nil, "Add Account", "ADD", custom) + okButton := CreateButton(nil, nil, "Add Account", "ADD", mouseClick) hboxButtons.Append(okButton, false) - backButton := CreateButton(nil, nil, "Back", "BACK", custom) + backButton := CreateButton(nil, nil, "Back", "BACK", mouseClick) hboxButtons.Append(backButton, false) - - return vbox } diff --git a/gui.go b/gui.go index e30ae96..45a9d6c 100644 --- a/gui.go +++ b/gui.go @@ -201,8 +201,9 @@ func CreateButton(a *pb.Config_Account, vm *pb.Event_VM, var newmap ButtonMap newmap.B = newB newmap.Account = a - newmap.Action = note - newmap.custom = custom + newmap.Action = note + newmap.custom = custom + newmap.aTab = Data.CurrentTab Data.AllButtons = append(Data.AllButtons, newmap) return newB diff --git a/mainCloudBox.go b/mainCloudBox.go index e418ebc..9765900 100644 --- a/mainCloudBox.go +++ b/mainCloudBox.go @@ -174,8 +174,18 @@ func ShowAccountTab() { log.Println("Sleep(200)") time.Sleep(200 * time.Millisecond) - Data.smallBox = AddAccountBox(mouseClick) - Data.cloudTab.InsertAt("Add Account", 0, Data.smallBox) + // Create the things for the Account Tab + var aTab GuiTabStructure + Data.CurrentTab = &aTab + AddAccountBox(&aTab) + + // Set the parents and data structure links + aTab.me = Data.cloudTab + aTab.parentWindow = Data.cloudWindow + aTab.tabOffset = 0 + +// Data.smallBox = aTab.firstBox + Data.cloudTab.InsertAt("Add Account", 0, aTab.firstBox) Data.cloudTab.SetMargined(0, true) } diff --git a/structs.go b/structs.go index e3c353e..bf9c860 100644 --- a/structs.go +++ b/structs.go @@ -20,6 +20,10 @@ type GuiTabStructure struct { firstBox *ui.Box tabOffset int + EntryNick *ui.Entry + EntryUser *ui.Entry + EntryPass *ui.Entry + // this means only one table per tab mh *TableData @@ -101,6 +105,7 @@ type ButtonMap struct { Account *pb.Config_Account VM *pb.Event_VM Action string // what type of button + aTab *GuiTabStructure custom func (*ButtonMap) }