1
votes

I am having a weird problem with my Blackberry Cascades application. I was trying to add a button to actionbar (at the bottom of the application). But when I test it in the Blackberry 10 Dev Alpha simulator (BB10_0_10.261) it seems that I have 2 (and sometimes 3) versions of the same button, as shown in the image below. While there should normally be only 1?

Too many buttons

So what I do is adding a button to my page in QML like so:

NavigationPane {
    Page {
        Container {
            layout: StackLayout {
            }
            ListView {
                ...
            }
        }
        actions: [
            ActionItem {
                title: "New Event"
                ActionBar.placement: ActionBarPlacement.OnBar // HERE
                onTriggered: {
                    var page = newEventPage.createObject();
                    navigationPane.push(page);
                }
                attachedObjects: ComponentDefinition {
                    id: newEventPage
                    source: "addEvent.qml"
                }
            }
        ]
    }
    onPopTransitionEnded: {
        page.destroy();
    }
}

This code does not a lot more than adding a button "New Event" that will link to my "addEvent.qml"

But if I remove (or comment) the line Actionbar.placement: ActionBarPlacement.OnBar (marked with HERE in the code above), I only get 1 button as was expected. But this button is situated in the overflow menu, while I want it on the ActionBar at the bottom.

All the different versions of the buttons do exactly the same thing (the expected behaviour by the way: opening addEvent.qml).

What I've already tried: "Clean.." and then "Rebuild"; this didn't work. I also tried to move the actions-array to other places, as I thought this could be on the wrong place, but this didn't help either. Removing the application on the simulator, and then reinstalling it.

I also tried it on a different computer, and other simulator, as I thought it could maybe be my computer. But I had the same problem there.

I don't know if this is a bug or not, but I guess I am doing something wrong, since I don't have a lot of experience in Cascades Development. I have looked everywhere, but haven't anybody else with the same problem. I haven't tested it on a real device, because I don't have a BB10 device (yet).

1

1 Answers

1
votes

I asked this question on the Blackberry Cascades forum, because I thought most of the experts would reside there. And apparantly, they could answer my question.

Apparantly the problem was that I used qml->setContextProperty("model", model); in my C++ code. And I thought that it didn't make a huge of difference, so I've put this line behind the line AbstractPane *root = qml->createRootObject<AbstractPane>(); But apparantly it does make a difference, because then you will receive your buttons double .

So this problem is actually fairly simple to solve when you know it, just move the setContextProperty lines before the createRootObject line and everything is solved.

And the problem I had with 3 buttons, seems to be that I had 2 setContextProperty lines of code, behind the createRootObject line. So for every setContextProperty line, the buttons were duplicated.