summaryrefslogtreecommitdiff
path: root/button.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2021-10-31 20:07:26 -0500
committerJeff Carr <[email protected]>2021-10-31 20:07:26 -0500
commit9bd0227844e0b6a6b7e507ea00bff4674a6e3167 (patch)
treea0dd35916fd0f40f624209af330eec2e2fd714ab /button.go
parent764513474f7f03ccc7be5369a8ea6e7bcbff9071 (diff)
BOX: keep removing GuiBox
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'button.go')
-rw-r--r--button.go98
1 files changed, 5 insertions, 93 deletions
diff --git a/button.go b/button.go
index 4d4e1d0..8135962 100644
--- a/button.go
+++ b/button.go
@@ -19,40 +19,6 @@ import _ "github.com/andlabs/ui/winmanifest"
// There is a []GuiButton which has all the buttons. We search
// for the button and then call the function below
//
-/*
-func defaultButtonClick(button *ui.Button) {
- log.Println("gui.defaultButtonClick() LOOK FOR BUTTON button =", button)
- for key, foo := range Data.AllButtons {
- if (Config.Debug) {
- log.Println("gui.defaultButtonClick() Data.AllButtons =", key, foo)
- // spew.Dump(foo)
- }
- if Data.AllButtons[key].B == button {
- log.Println("\tgui.defaultButtonClick() BUTTON MATCHED")
- guiButtonClick(Data.AllButtons[key])
- return
- }
- }
- log.Println("\tgui.defaultButtonClick() ERROR: BUTTON NOT FOUND")
- if (Config.Debug) {
- panic("gui.defaultButtonClick() ERROR: UNMAPPED ui.Button")
- }
-}
-
-func guiButtonClick(button *GuiButton) {
- log.Println("\tgui.guiButtonClick() button.Name =", button.Name)
- if button.Custom != nil {
- log.Println("\tgui.guiButtonClick() DOING CUSTOM FUNCTION")
- button.Custom(button)
- return
- }
- if (Data.MouseClick != nil) {
- Data.MouseClick(button)
- } else {
- log.Println("\tgui.guiButtonClick() IGNORING BUTTON. MouseClick() is nil")
- }
-}
-*/
func (n *Node) AddButton(name string, custom func(*Node)) *Node {
if (n.uiBox == nil) {
@@ -79,66 +45,12 @@ func (n *Node) AddButton(name string, custom func(*Node)) *Node {
return newNode
}
-/*
-func (n *Node) CreateButton(custom func(*GuiButton), name string, values interface {}) *Node {
- newNode := n.AddBox(Xaxis, "test CreateButton")
- box := newNode.FindBox()
- if (box == nil) {
- panic("node.CreateButton().FindBox() == nil")
- }
- newUiB := ui.NewButton(name)
- newUiB.OnClicked(defaultButtonClick)
-
- var newB *GuiButton
- newB = new(GuiButton)
- newB.B = newUiB
- if (box.UiBox == nil) {
- log.Println("CreateButton() box.Window == nil")
- // ErrorWindow(box.Window, "Login Failed", msg) // can't even do this
- panic("maybe print an error and return nil? or make a fake button?")
- } else {
- // uibox := box.UiBox
- // uibox.Append(newUiB, true)
- }
- newB.Box = box
- newB.Custom = custom
- newB.Values = values
-
- Data.AllButtons = append(Data.AllButtons, newB)
-
- box.Append(newB.B, false)
- return newNode
-}
-
-func CreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
- newUiB := ui.NewButton(name)
- newUiB.OnClicked(defaultButtonClick)
-
- var newB *GuiButton
- newB = new(GuiButton)
- newB.B = newUiB
- if (box.Window == nil) {
- log.Println("CreateButton() box.Window == nil")
- // ErrorWindow(box.Window, "Login Failed", msg) // can't even do this
- panic("maybe print an error and return nil? or make a fake button?")
- }
- newB.Box = box
- newB.Custom = custom
- newB.Values = values
-
- Data.AllButtons = append(Data.AllButtons, newB)
-
- box.Append(newB.B, false)
- return newB
-}
-*/
-
-func CreateFontButton(box *GuiBox, action string) *GuiButton {
+func CreateFontButton(n *Node, action string) *GuiButton {
// create a 'fake' button entry for the mouse clicks
var newGB GuiButton
newGB.Name = "FONT"
newGB.FB = ui.NewFontButton()
- newGB.Box = box
+ newGB.Box = n.box
Data.AllButtons = append(Data.AllButtons, &newGB)
newGB.FB.OnChanged(func (*ui.FontButton) {
@@ -150,12 +62,12 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
return &newGB
}
-func CreateColorButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
+func CreateColorButton(n *Node, custom func(*GuiButton), name string, values interface {}) *GuiButton {
// create a 'fake' button entry for the mouse clicks
var newCB GuiButton
newCB.Name = name
newCB.CB = ui.NewColorButton()
- newCB.Box = box
+ newCB.Box = n.box
newCB.Custom = custom
newCB.Values = values
@@ -171,6 +83,6 @@ func CreateColorButton(box *GuiBox, custom func(*GuiButton), name string, values
Data.MouseClick(&newCB)
}
})
- box.Append(newCB.CB, false)
+ n.box.Append(newCB.CB, false)
return &newCB
}