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: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Move ActionItem from Onbar to Overflow and vise versa

Did anyone try to change dynamically the placement of ActionItem from Action Bar to Overflow and vise versa?

 

Here's what I tried:

I created all ActionItems in QML part, so I have all objects created. All ActionItems have "Default" placement (which according to docs is same as "InOverflow") Then depends on conditions I remove/add ActionItems from /on page.

 

What I have:

Doesn't matter if I add ActionItems with "OnBar" placement or with "InOverflow" they all appears in overflow part. Which of course is not what I always want.

 

Seems like initial placement is somehow important ( remember "default"? ).

 

I'm going to try one more time with all ActionItems created and managed in. cpp part, in the meantime may be somebody can share his/her experience how to make it work right if it's possible to get it work at all.

 

 

Thanks.

Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Move ActionItem from Onbar to Overflow and vise versa

Yea I never understood why all actions are in the overflow. Maybe it's pre-emptive planning for keyboard devices? since a simple tap of a menu button or the like would open up the overflow showing all options. For touch interfaces the design of having redundant actions in the overflow is a pain.
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Move ActionItem from Onbar to Overflow and vise versa

I have an app where I also need specific action items onBar, others in the overflow, and again others being disabled when certain conditions are met. What I did was crosschecking everything in the onCompleted-call (I think that was its name) of my page and then setting the ActionItems

If it helps, I can give you my code
-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Move ActionItem from Onbar to Overflow and vise versa

OnBar items also appear in overflow, this is by design and cannot be changed. you could implement your own action bar for a custom behavior, but note that users most likely expect the native experience.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Move ActionItem from Onbar to Overflow and vise versa

@pyth:

Are you doing it only in OnCompleted()? Cause it's not enough for me. In my case I have to move/show items not only initially but also based on incoming signals. If you can share your code it would be really nice, I will definitely look into it.

 

I still didn't have a chance to try create everything dynamically, too busy with other things. But as soon as I try I'll post my findings.

 

Developer
Posts: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Move ActionItem from Onbar to Overflow and vise versa

@simon_hain:

Yes, thank you, I know. I think I wasn't clear in my question. It's not like really moving item from Active Bar to Overflow and vice versa. It's more like dynamically changing items in the Action Bar using items in Overflow depending on some changing in time condition.

 

It's good that you mentioned native experience, because while I still want to implement my feature I can't stop thinking if it will be really useful feature not only for me but for other people. But first I want to try it so I have to implement it. Also in defense of my idea I was thinking about any Media Player/mp3 player. Most implementations replace play button with pause button and it's expected. In my case I almost do the same.

 

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

Re: Move ActionItem from Onbar to Overflow and vise versa


scrudrv wrote:....Also in defense of my idea I was thinking about any Media Player/mp3 player. Most implementations replace play button with pause button and it's expected. In my case I almost do the same.

 


I'm doing this always.

changing the Image and title depending on state works well

 

isRunning? "Pause":"Start"

-------------------------------------------------------------------------------
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: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Move ActionItem from Onbar to Overflow and vise versa

[ Edited ]

@ekke. You actually gave me another idea, I think I'm going to make all those buttons in ActiveBar and play with Visible/Not Visible...

 

And if I don't like it then... probably your way Smiley Happy

 

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

Re: Move ActionItem from Onbar to Overflow and vise versa


scrudrv wrote:

@ekke. You actually gave me another idea, I think I'm going to make all those buttons in ActiveBar and play with Visible/Not Visible...

 

And if I don't like it then... probably your way Smiley Happy

 


ActionItems don't have a visible / invisible property

 

here's what I'm doing

 

            ActionItem {
                id: startStopAction
                title: trackedTimeContainer.running ? qsTr("Stop") : qsTr("Start")
                ActionBar.placement: ActionBarPlacement.OnBar
                imageSource: trackedTimeContainer.running ? "asset:///images/stop.png" : "asset:///images/go.png"
                onTriggered: {
                    if (trackedTimeContainer.running) {
                        pushTimeStopper()
                    } else {
                        pushTimeStarter()
                    }
                }
                shortcuts: [
                    Shortcut {
                        enabled: trackedTimeContainer.running
                        key: qsTr("s")
                        
                    },
                    Shortcut {
                        enabled: !trackedTimeContainer.running
                        key: qsTr("g")
                    }
                ]
            }

 


perhaps give you an idea

 

 

-------------------------------------------------------------------------------
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: 47
Registered: ‎11-23-2010
My Device: Q10
My Carrier: Rogers

Re: Move ActionItem from Onbar to Overflow and vise versa

[ Edited ]

@ekke Thanks for code, your solution is good and I like it. But in my case I have to go from having 1 button in OnBar to 3 buttons and vice versa. Means I can't just change image and title I have to remove at least 2 buttons.

 

So I got back to my initial idea. Just created in qml all items with placement "OnBar" (before I used Deafult). Then depends on conditions I use removeAction() or addAction(). Looks like it works as I wanted. Will see if I like it or get back to waht I had before.