move logic from qml to GO

This commit is contained in:
lordwelch 2016-03-17 09:41:21 -07:00
parent d483570591
commit ca47264f51
2 changed files with 16 additions and 15 deletions

13
main.go
View File

@ -293,6 +293,19 @@ func (cl *cell) setSignal() {
setupScene()
})
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
if focus {
cl.qmlcell.ObjectByName("cellMouse").Call("selected")
} else {
cl.qmlcell.ObjectByName("cellMouse").Call("notSelected")
}
})
cl.qmlcell.ObjectByName("cellMouse").On("Clicked", func() {
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
cl.qmlcell.ObjectByName("cellMouse").Call("selected")
})
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
textEdit.Set("cell", cl.index)

View File

@ -28,17 +28,6 @@ Rectangle {
enabled: true
objectName: "cellMouse"
anchors.fill: parent
onFocusChanged: if (focus) {
selected()
} else {
notSelected()
}
onClicked: {
focus = true
selected()
mouseXChanged(mouse)
}
onMouseXChanged: if (containsMouse) {
parent.parent.border.color = "skyblue"
@ -48,21 +37,20 @@ Rectangle {
parent.color = "black"
}
onExited: notSelected()
onExited: focusChanged(focus)
function notSelected() {
parent.parent.border.color = "black"
parent.parent.color = "white"
parent.color = "black"
if (focus) {
focusChanged(focus)
}
MouseXChanged(mouse)
}
function selected() {
parent.parent.border.color = "blue"
parent.parent.color = "gainsboro"
MouseXChanged(mouse)
}
}
}