Commit e2b8964c authored by J-P Nurmi's avatar J-P Nurmi
Browse files

Android: fix missing cursor handle


Change-Id: Iefd5ed9b662423c25d5dcad011d93b2336da794a
Reviewed-by: default avatarMitch Curtis <mitch.curtis@digia.com>
Showing with 30 additions and 45 deletions
...@@ -45,66 +45,51 @@ import "drawables" ...@@ -45,66 +45,51 @@ import "drawables"
DrawableLoader { DrawableLoader {
id: delegate id: delegate
property bool active: false
property bool hasText: !!editor.text || !!editor.displayText
styleDef: styleData.hasSelection ? AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleRight styleDef: styleData.hasSelection ? AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleRight
: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandle : AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandle
x: styleData.hasSelection ? -width / 4 : -width / 2 x: styleData.hasSelection ? -width / 4 : -width / 2
y: styleData.lineHeight y: styleData.lineHeight
opacity: 1.0
pressed: styleData.pressed pressed: styleData.pressed
focused: control.activeFocus focused: control.activeFocus
window_focused: focused && control.Window.active window_focused: focused && control.Window.active
Connections { opacity: hasText && (styleData.hasSelection || styleData.pressed || idle.running) ? 1.0 : 0.0
target: editor
ignoreUnknownSignals: true Timer {
onDisplayTextChanged: { id: idle
delegate.state = "hidden" repeat: false
} interval: 4000
} }
Connections { Connections {
target: styleData target: styleData
onActivated: { onActivated: idle.restart()
if (editor.text) { onPressedChanged: {
delegate.active = true if (!styleData.pressed)
delegate.opacity = 1.0 idle.restart()
delegate.state = ""
if (!styleData.hasSelection)
delegate.state = "idle"
}
} }
} }
state: "hidden" // Hide the cursor handle on textual changes, unless the signals are
// indirectly triggered by activating/tapping/moving the handle. When
states: [ // text prediction is enabled, the textual content may change when the
State { // cursor moves and the predicted text is committed.
name: "hidden" Connections {
when: editor.inputMethodComposing && !delegate.active && !editor.text target: editor
}, ignoreUnknownSignals: true
State { onTextChanged: if (!ignore.running) idle.stop()
name: "idle" onDisplayTextChanged: if (!ignore.running) idle.stop()
when: !styleData.hasSelection && !styleData.pressed onInputMethodComposing: if (!ignore.running) idle.stop()
} }
]
transitions: [ Timer {
Transition { id: ignore
to: "hidden" repeat: false
SequentialAnimation { interval: 250
PauseAnimation { duration: 100 } running: idle.running
PropertyAction { target: delegate; property: "opacity"; value: 0.0 } }
}
},
Transition {
to: "idle"
SequentialAnimation {
PauseAnimation { duration: 4000 }
NumberAnimation { target: delegate; property: "opacity"; to: 0.0 }
PropertyAction { target: delegate; property: "active"; value: false }
}
}
]
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment