Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 181
Registered: ‎07-19-2012
My Device: Q5, Q10, Z10, Z30, PlayBook
My Carrier: Carrier
Accepted Solution

How to remove ActionItem from page

Consider the following QML:

Page {
   actions: [
ActionItem { id: action1 }
]
}

   How would I (in QML) remove the action1 from the Action Bar? 

 

The property action1.visible does not exist.

 

I guess if I could get somehow reference of the ActionSet of the actions in the ActionBar I could just call the actionSet.remove(index) function but I can't seem to be able to get ActionSet for the items in the Action Bar??

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to remove ActionItem from page

this is an easy job:

 

on the Page you say

 

addAction(action1)

 

or removeAction(action1)

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Highlighted
Developer
Posts: 181
Registered: ‎07-19-2012
My Device: Q5, Q10, Z10, Z30, PlayBook
My Carrier: Carrier

Re: How to remove ActionItem from page

Thanks. Not sure how I missed that!

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: How to remove ActionItem from page

This is not working in QML. What is the code to remove ActionItems in CPP?

 

Thank you!

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to remove ActionItem from page


greenback wrote:

This is not working in QML. What is the code to remove ActionItems in CPP?

 

Thank you!


doing this always from QML

 

hint: the only thing you shouldn't do: removeAll ActionItems - always explicite name the Actionitems to be removed or added

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: How to remove ActionItem from page

Hi Ekke,
Thank you for the quick reply. I am using OS 10.3 and it is not working. I have attached my code below.

I have absolutely no clue why it's not working. Any help would be greatly appreciated.

import bb.cascades 1.3 

NavigationPane {
            id:nav

            Page {
                id: mypage
                actions: [
                    ActionItem {
                        id: refreshAction
                        title: qsTr("Refresh")
                        onTriggered: {
                            dataSource.load()
                        }
                    },
                    ActionItem {
                        id: sendAction
                        objectName: "sendAction"
                        title: "Send Message"
                        imageSource: "asset:///icons/sm.png"
                        ActionBar.placement: ActionBarPlacement.Signature
                    },
                    ActionItem {
                        id: attachAction
                        objectName: "attachAction"
                        title:"Attach"
                        imageSource:"asset:///icons/attach.png"
                        ActionBar.placement:ActionBarPlacement.Signature
                    },
                    ActionItem {
                        id: emoticonAction
                        objectName: "emoticonAction"
                        title:"Emoticons"
                        imageSource:"asset:///icons/emoticon.png"
                        ActionBar.placement:ActionBarPlacement.Signature
                        //backgroundColor:Color.create(0.96,0.37,0.06)
                    },
                    TextInputActionItem {
                        id: inputAction
                        objectName: "inputAction"
                        text: ""
                        hintText: "Enter a message"
                        input.flags: TextInputFlag.PredictionOff
                        input.keyLayout: KeyLayout.Text
                        input {
                            submitKey: SubmitKey.Send
                            onSubmitted: {
                                label5.text = inputAction.text;
                                inputAction.text = "";
                            }
                        }
                    }
                ]
                Container {
                    background: Color.Black
                    preferredHeight: 720
                    preferredWidth: 720
                    layout: DockLayout {

                    }


Button{
                                            preferredWidth: 90
                                            text: "REMBAR"
                                            onClicked: {
                                               removeAction(emoticonAction);
                                               removeAction(inputAction)
                                               removeAction(attachAction);
                                               removeAction(sendAction);
                                            }
                                        }
}//end inner container
}//end page
}//end nav

 

ERRORS FROM CONSOLE

 

TypeError: Result of expression 'removeAction' [undefined] is not a function.

 

 

 

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: How to remove ActionItem from page

Can you try it with myPage.removeAction()?

______________________________________________________
BB10-OAuth: GitHub
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to remove ActionItem from page

[ Edited ]

here's a typical use-case

 

Page {
    id: artikelHeaderPage
    property string currentRNummer: "-1"
    onCurrentRNummerChanged: {
        if(currentRNummer == -1){
            artikelHeaderPage.removeAction(doneAction)
            artikelHeaderPage.removeAction(artikelAction)
            artikelHeaderPage.addAction(downloadAction)
        } else {
            artikelHeaderPage.removeAction(downloadAction)
            artikelHeaderPage.addAction(artikelAction)
            artikelHeaderPage.addAction(doneAction)
        }
    }

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: How to remove ActionItem from page

The solution with the property string reference worked. Thank you!!!!