on xenial help sign in
add some checks if we actually clicked an item or in the spacing between them

gets rid of some warnings printed by the launcher

commitf1f4370ff990f138dc377420472ffeb7465df0d4 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 20 Aug 2013, 15:01 (13 years ago) parent2563253
1 file changed+14−2
Launcher/LauncherPanel.qml+14−2
Launcher/LauncherPanel.qml+14−2
@@ -233,7 +233,7 @@ Item {
233233 property int draggedIndex: -1
234234 property var selectedItem
235235 property bool preDragging: false
236− property bool dragging: selectedItem !== undefined && selectedItem.dragging
236+ property bool dragging: selectedItem !== undefined && selectedItem !== null && selectedItem.dragging
237237 property bool postDragging: false
238238 property int startX
239239 property int startY
@@ -241,13 +241,21 @@ Item {
241241
242242 onPressed: {
243243 selectedItem = launcherListView.itemAt(mouseX, mouseY + launcherListView.realContentY)
244− selectedItem.highlighted = true
244+ if (selectedItem !== null) {
245+ selectedItem.highlighted = true
246+ }
245247 }
246248
247249 onClicked: {
248250 var index = Math.floor((mouseY + launcherListView.realContentY) / launcherListView.realItemHeight);
249251 var clickedItem = launcherListView.itemAt(mouseX, mouseY + launcherListView.realContentY)
250252
253+ // Check if we actually clicked an item or only at the spacing in between
254+ if (clickedItem === null) {
255+ return;
256+ }
257+
258+ print("index is", index)
251259 // First/last item do the scrolling at more than 12 degrees
252260 if (index == 0 || index == launcherListView.count - 1) {
253261 if (clickedItem.angle > 12) {
@@ -278,6 +286,10 @@ Item {
278286 }
279287
280288 onReleased: {
289+ if (draggedIndex == -1) {
290+ return;
291+ }
292+
281293 var droppedIndex = draggedIndex;
282294 if (dragging) {
283295 postDragging = true;