standardize other mouse clicks
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b251151328
commit
4f08c8f1ce
49
gui.go
49
gui.go
|
@ -143,23 +143,19 @@ func mouseClick(b *ButtonMap) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
func buttonMapClick(b *ButtonMap) {
|
// This routine MUST be here as this is how the andlabs/ui works
|
||||||
log.Println("gui.buttonVmClick() START")
|
|
||||||
if (Data.MouseClick == nil) {
|
|
||||||
log.Println("Data.MouseClick() IS nil. NOT DOING ANYTHING")
|
|
||||||
} else {
|
|
||||||
log.Println("Data.MouseClick() START")
|
|
||||||
Data.MouseClick(b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This is the raw routine passed to every button in andlabs libui / ui
|
// This is the raw routine passed to every button in andlabs libui / ui
|
||||||
|
//
|
||||||
|
// There is a []ButtonMap which has all the buttons. We search
|
||||||
|
// for the button and then call the function below
|
||||||
|
//
|
||||||
func defaultButtonClick(button *ui.Button) {
|
func defaultButtonClick(button *ui.Button) {
|
||||||
log.Println("defaultButtonClick() button =", button)
|
log.Println("defaultButtonClick() LOOK FOR BUTTON button =", button)
|
||||||
for key, foo := range Data.AllButtons {
|
for key, foo := range Data.AllButtons {
|
||||||
log.Println("Data.AllButtons =", key, foo)
|
if (Data.Debug) {
|
||||||
|
log.Println("Data.AllButtons =", key, foo)
|
||||||
|
}
|
||||||
if Data.AllButtons[key].B == button {
|
if Data.AllButtons[key].B == button {
|
||||||
log.Println("\tBUTTON MATCHED")
|
log.Println("\tBUTTON MATCHED")
|
||||||
// log.Println("\tData.AllButtons[key].Name =", Data.AllButtons[key].Name)
|
// log.Println("\tData.AllButtons[key].Name =", Data.AllButtons[key].Name)
|
||||||
|
@ -179,12 +175,17 @@ func defaultButtonClick(button *ui.Button) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("\tBUTTON NOT FOUND")
|
log.Println("\tBUTTON NOT FOUND")
|
||||||
// still run the mouse click handler
|
if (Data.Debug) {
|
||||||
|
panic("SHOULD NOT HAVE UNMAPPED BUTTONS")
|
||||||
|
}
|
||||||
|
// still run the mouse click handler if you got here
|
||||||
|
// TODO: get rid of this to make sure everything is perfectly mapped
|
||||||
if (Data.MouseClick != nil) {
|
if (Data.MouseClick != nil) {
|
||||||
Data.MouseClick(nil)
|
Data.MouseClick(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// This is the raw routine passed to every button in andlabs libui / ui
|
// This is the raw routine passed to every button in andlabs libui / ui
|
||||||
// (this has to be different for FontButtons)
|
// (this has to be different for FontButtons)
|
||||||
// TODO; merge the logic with the function above
|
// TODO; merge the logic with the function above
|
||||||
|
@ -194,6 +195,7 @@ func defaultFontButtonClick(button *ui.FontButton) {
|
||||||
log.Println("Data.AllButtons =", key, foo)
|
log.Println("Data.AllButtons =", key, foo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func CreateButton(a *pb.Account, vm *pb.Event_VM,
|
func CreateButton(a *pb.Account, vm *pb.Event_VM,
|
||||||
name string, note string, custom func(*ButtonMap)) *ui.Button {
|
name string, note string, custom func(*ButtonMap)) *ui.Button {
|
||||||
|
@ -212,16 +214,17 @@ func CreateButton(a *pb.Account, vm *pb.Event_VM,
|
||||||
return newB
|
return newB
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateFontButton(name string, note string, custom func(*ButtonMap)) *ui.FontButton {
|
func CreateFontButton(action string, note string, custom func(*ButtonMap)) *ui.FontButton {
|
||||||
newB := ui.NewFontButton()
|
newB := ui.NewFontButton()
|
||||||
|
|
||||||
newB.OnChanged(defaultFontButtonClick)
|
// create a 'fake' button entry for the mouse clicks
|
||||||
|
var newButtonMap ButtonMap
|
||||||
var newmap ButtonMap
|
newButtonMap.Action = action
|
||||||
newmap.FB = newB
|
newButtonMap.FB = newB
|
||||||
newmap.Action = note
|
Data.AllButtons = append(Data.AllButtons, newButtonMap)
|
||||||
newmap.custom = custom
|
|
||||||
Data.AllButtons = append(Data.AllButtons, newmap)
|
|
||||||
|
|
||||||
|
newB.OnChanged(func (*ui.FontButton) {
|
||||||
|
mouseClick(&newButtonMap)
|
||||||
|
})
|
||||||
return newB
|
return newB
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,20 +209,18 @@ func GoMainWindow() {
|
||||||
func makeCloudWindow() {
|
func makeCloudWindow() {
|
||||||
Data.cloudWindow = ui.NewWindow("", Data.Width, Data.Height, true)
|
Data.cloudWindow = ui.NewWindow("", Data.Width, Data.Height, true)
|
||||||
// cloudWindow.SetBorderless(true)
|
// cloudWindow.SetBorderless(true)
|
||||||
|
|
||||||
|
// create a 'fake' button entry for the mouse clicks
|
||||||
|
var newButtonMap ButtonMap
|
||||||
|
newButtonMap.Action = "QUIT"
|
||||||
|
Data.AllButtons = append(Data.AllButtons, newButtonMap)
|
||||||
|
|
||||||
Data.cloudWindow.OnClosing(func(*ui.Window) bool {
|
Data.cloudWindow.OnClosing(func(*ui.Window) bool {
|
||||||
if (Data.MouseClick != nil) {
|
mouseClick(&newButtonMap)
|
||||||
log.Println("SIMULATE Data.MouseClick(QUIT)")
|
|
||||||
Data.State = "QUIT"
|
|
||||||
Data.MouseClick(nil)
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
ui.OnShouldQuit(func() bool {
|
ui.OnShouldQuit(func() bool {
|
||||||
if (Data.MouseClick != nil) {
|
mouseClick(&newButtonMap)
|
||||||
log.Println("SIMULATE Data.MouseClick(QUIT)")
|
|
||||||
Data.State = "QUIT"
|
|
||||||
Data.MouseClick(nil)
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue