move logic from qml to GO
This commit is contained in:
parent
d483570591
commit
ca47264f51
13
main.go
13
main.go
@ -293,6 +293,19 @@ func (cl *cell) setSignal() {
|
|||||||
setupScene()
|
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() {
|
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
||||||
|
|
||||||
textEdit.Set("cell", cl.index)
|
textEdit.Set("cell", cl.index)
|
||||||
|
18
qml/cell.qml
18
qml/cell.qml
@ -28,17 +28,6 @@ Rectangle {
|
|||||||
enabled: true
|
enabled: true
|
||||||
objectName: "cellMouse"
|
objectName: "cellMouse"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onFocusChanged: if (focus) {
|
|
||||||
selected()
|
|
||||||
} else {
|
|
||||||
notSelected()
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
focus = true
|
|
||||||
selected()
|
|
||||||
mouseXChanged(mouse)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMouseXChanged: if (containsMouse) {
|
onMouseXChanged: if (containsMouse) {
|
||||||
parent.parent.border.color = "skyblue"
|
parent.parent.border.color = "skyblue"
|
||||||
@ -48,21 +37,20 @@ Rectangle {
|
|||||||
parent.color = "black"
|
parent.color = "black"
|
||||||
}
|
}
|
||||||
|
|
||||||
onExited: notSelected()
|
onExited: focusChanged(focus)
|
||||||
|
|
||||||
function notSelected() {
|
function notSelected() {
|
||||||
|
|
||||||
parent.parent.border.color = "black"
|
parent.parent.border.color = "black"
|
||||||
parent.parent.color = "white"
|
parent.parent.color = "white"
|
||||||
parent.color = "black"
|
parent.color = "black"
|
||||||
if (focus) {
|
MouseXChanged(mouse)
|
||||||
focusChanged(focus)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selected() {
|
function selected() {
|
||||||
parent.parent.border.color = "blue"
|
parent.parent.border.color = "blue"
|
||||||
parent.parent.color = "gainsboro"
|
parent.parent.color = "gainsboro"
|
||||||
|
MouseXChanged(mouse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user