253.4.1
by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page. |
1 |
/*
|
400.1.2
by mihirsoni-123
updated copyright year |
2 |
* Copyright (C) 2013-2014 Canonical Ltd
|
400.1.1
by mihirsoni-123
Added copyright header comments in all the pages |
3 |
*
|
4 |
* This file is part of Ubuntu Calendar App
|
|
5 |
*
|
|
6 |
* Ubuntu Calendar App is free software: you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License version 3 as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* Ubuntu Calendar App is distributed in the hope that it will be useful,
|
|
253.4.1
by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page. |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
*/
|
|
18 |
||
463.1.1
by Akiva Avraham
Updated library imports to qtquick-2.3 |
19 |
import QtQuick 2.3 |
253.4.1
by Renato Araujo Oliveira Filho
Make sure that the field is always visible on NewEvent page. |
20 |
|
21 |
Item { |
|
22 |
id: keyboardRect
|
|
23 |
anchors.left: parent.left |
|
24 |
anchors.right: parent.right |
|
25 |
anchors.bottom: parent.bottom |
|
26 |
height: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 |
|
27 |
||
28 |
Behavior on height { |
|
29 |
NumberAnimation { |
|
30 |
duration: 300 |
|
31 |
easing.type: Easing.InOutQuad |
|
32 |
}
|
|
33 |
}
|
|
34 |
||
35 |
states: [ |
|
36 |
State { |
|
37 |
name: "hidden" |
|
38 |
when: keyboardRect.height == 0 |
|
39 |
},
|
|
40 |
State { |
|
41 |
name: "shown" |
|
42 |
when: keyboardRect.height == Qt.inputMethod.keyboardRectangle.height |
|
43 |
}
|
|
44 |
]
|
|
45 |
||
46 |
function recursiveFindFocusedItem(parent) { |
|
47 |
if (parent.activeFocus) { |
|
48 |
return parent; |
|
49 |
}
|
|
50 |
||
51 |
for (var i in parent.children) { |
|
52 |
var child = parent.children[i]; |
|
53 |
if (child.activeFocus) { |
|
54 |
return child; |
|
55 |
}
|
|
56 |
||
57 |
var item = recursiveFindFocusedItem(child); |
|
58 |
||
59 |
if (item != null) { |
|
60 |
return item; |
|
61 |
}
|
|
62 |
}
|
|
63 |
||
64 |
return null; |
|
65 |
}
|
|
66 |
||
67 |
Connections { |
|
68 |
target: Qt.inputMethod |
|
69 |
||
70 |
onVisibleChanged: { |
|
71 |
if (!Qt.inputMethod.visible) { |
|
72 |
var focusedItem = recursiveFindFocusedItem(keyboardRect.parent); |
|
73 |
if (focusedItem != null) { |
|
74 |
focusedItem.focus = false; |
|
75 |
}
|
|
76 |
}
|
|
77 |
}
|
|
78 |
}
|
|
79 |
}
|