Put editbubble below cursor when there's not enough space above it
Also clean up a bit here and there, removing redundancy
This commit is contained in:
parent
b6f545c433
commit
10b4ad517d
@ -25,13 +25,10 @@ PlasmaCore.FrameSvgItem {
|
||||
id: editBubble
|
||||
objectName: "editBubble"
|
||||
property int iconSize: 32;
|
||||
//property alias cursorPosition: textInput.cursorPosition;
|
||||
property variant cursorPosition: "0,0"
|
||||
|
||||
imagePath: "dialogs/background"
|
||||
width: (iconSize*2) + iconSize
|
||||
height: iconSize*2
|
||||
z: 1
|
||||
z: 100000
|
||||
//anchors { top: parent.bottom; right: parent.right; topMargin: -(iconSize/4); }
|
||||
|
||||
// fully dynamic show / hide
|
||||
@ -79,12 +76,6 @@ PlasmaCore.FrameSvgItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
onCursorPositionChanged: {
|
||||
//if (typeof(cursorPosition == "undefined")) return;
|
||||
//print(" new cursorPosition: " + cursorPosition.x + "," + cursorPosition.y);
|
||||
x = cursorPosition.x - parent.width/2
|
||||
y = cursorPosition.y - parent.height
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
id: expanded
|
||||
|
@ -188,7 +188,7 @@ Item {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
print("clear button clicked");
|
||||
//print("clear button clicked");
|
||||
textInput.text = "";
|
||||
textInput.forceActiveFocus();
|
||||
editBubble.state = "collapsed"
|
||||
@ -203,24 +203,36 @@ Item {
|
||||
//onPressed: print(" MouseEventListener Pressed");
|
||||
onPressAndHold: {
|
||||
print(" *** MouseEventListener PressAndHold");
|
||||
editBubble.cursorPosition = mouse;
|
||||
editBubble.x = mouse.x-(editBubble.width/2)
|
||||
editBubble.y = mouse.y-editBubble.height-8
|
||||
placeEditBubble(mouse);
|
||||
editBubble.state = (textInput.activeFocus && (textInput.selectedText != "" || textInput.canPaste)) ? "expanded" : "collapsed";
|
||||
//editBubble.state = "expanded"
|
||||
}
|
||||
onPositionChanged: {
|
||||
//print(" positionChanged: " + mouse.x + "," + mouse.y);
|
||||
//if (typeof(mouse) == "undefined") return;
|
||||
editBubble.cursorPosition = mouse;
|
||||
placeEditBubble(mouse);
|
||||
}
|
||||
}
|
||||
|
||||
function placeEditBubble(mouse) {
|
||||
// Find the root item, then map our cursor position to it
|
||||
// in order to check if the edit bubble could end up off-screen
|
||||
var rootItem = parent;
|
||||
while (rootItem.parent) {
|
||||
rootItem = rootItem.parent;
|
||||
}
|
||||
var distanceToTop = mouseEventListener.mapToItem(rootItem, mouse.x, mouse.y);
|
||||
print( " distanceToTop: " + distanceToTop.y);
|
||||
if (distanceToTop.y > editBubble.height) {
|
||||
editBubble.x = mouse.x-(editBubble.width/2)
|
||||
editBubble.y = mouse.y-editBubble.height-8
|
||||
} else {
|
||||
editBubble.x = mouse.x-(editBubble.width/2)
|
||||
editBubble.y = mouse.y+8
|
||||
}
|
||||
|
||||
}
|
||||
onActiveFocusChanged: {
|
||||
if (!activeFocus) {
|
||||
editBubble.state = "collapsed";
|
||||
print("Hiding...");
|
||||
//print("Hiding...");
|
||||
}
|
||||
}
|
||||
}
|
@ -181,7 +181,7 @@ Column {
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
interval: 25
|
||||
interval: 100
|
||||
onTriggered: parent.value = (parent.value + 1) % 1.1
|
||||
}
|
||||
}
|
||||
|
@ -47,12 +47,13 @@ PlasmaComponents.Page {
|
||||
|
||||
Column {
|
||||
id: editThing
|
||||
anchors.centerIn: parent
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 300
|
||||
height: 300
|
||||
|
||||
spacing: 12
|
||||
Item { height: 60; width: parent.width; }
|
||||
Item { height: 4; width: parent.width; }
|
||||
PlasmaComponents.TextField {
|
||||
placeholderText: "Try copy & paste"
|
||||
text: "The cat bites into the socks"
|
||||
|
Loading…
Reference in New Issue
Block a user