diff --git a/main.go b/main.go index 2842b4d..79a9188 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/qml/cell.qml b/qml/cell.qml index 67f012e..1e19232 100644 --- a/qml/cell.qml +++ b/qml/cell.qml @@ -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) } } }