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
Bluenoser
Posts: 313
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook
Accepted Solution

Beta 3: Preventing Duplicate SettingsActionItem

Hi,

 

  I am able to get a settings screen from calling SettingsActionItem. The problem is that it can be called multiple times. How would you prevent this?

 

  Here is my code:

 

NavigationPane {
    id: navigationPane

    Menu.definition: MenuDefinition {
        settingsAction: SettingsActionItem {
            imageSource: "asset:///icons/setting.png"
            onTriggered: {
                var page = pageDefinition.createObject();
                navigationPane.push(page);
             }
             attachedObjects: ComponentDefinition {
                 id: pageDefinition;
                 source: "Settings.qml";
             }
         }               
     } 

 

Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Beta 3: Preventing Duplicate SettingsActionItem

I'm not really sure I understand the problem. Shouldn't the user be able to open the settings screen more than once?

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Bluenoser
Posts: 313
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Beta 3: Preventing Duplicate SettingsActionItem

I guess I should have been more clear.

 

The problem is that when you open up the settings screen, you can do a down swipe and open the settings screen from the settings screen, etc until you can be multiple screens deep into the settings screen. I was trying to say that you should only have the settings screen open once.

Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Beta 3: Preventing Duplicate SettingsActionItem

Ahh, yes, I see what you mean. I would recommend using a boolean to track whether you are currently displaying the settings screen or not, and only push the screen if it's not currently visible.
Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Bluenoser
Posts: 313
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Beta 3: Preventing Duplicate SettingsActionItem

@PBernhardt

 

That is what I thought. I was hoping for a different way.  Here is what I did so others can do the same. This is in the main.qml file.

 

NavigationPane {
    id: navigationPane
    
    onPopTransitionEnded: page.destroy()

    Menu.definition: MenuDefinition {
        settingsAction: SettingsActionItem {
            imageSource: "asset:///icons/setting.png"
            onTriggered: {
                if (_App.m_AppMenuActive == false) {
                    _App.appMenuActiveSetValue(true);
                    var page = pageDefinition.createObject();
                    navigationPane.push(page);
                }
             }
             attachedObjects: ComponentDefinition {
                 id: pageDefinition;
                 source: "Settings.qml";
             }
         }               
     } 

 This is in the Settings.qml file.

 

    paneProperties: NavigationPaneProperties {
        backButton: ActionItem {
            title: "Back"
            imageSource: "asset:///icons/prev.jpg"
            onTriggered: {
                _App.appMenuActiveSetValue(false);
                navigationPane.pop();
            }
        }
    }

 

In the .cpp file.

 

bool App::appMenuActiveValue() {
	return m_AppMenuActive;
}

void App::appMenuActiveSetValue(bool i) {
	m_AppMenuActive = i;
}

 In the .hpp file.

 

    Q_PROPERTY(bool m_AppMenuActive READ appMenuActiveValue WRITE appMenuActiveSetValue)

    Q_INVOKABLE
    void appMenuActiveSetValue(bool i);

    bool appMenuActiveValue();

private:
    bool m_AppMenuActive;

 

 

Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30

Re: Beta 3: Preventing Duplicate SettingsActionItem

Thank you for following up with your solution!
Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
ekke
Posts: 1,568
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Beta 3: Preventing Duplicate SettingsActionItem

I'm using a Sheet for Settings from Application Menu

then - while editing the settings I cannot open them again from swipe-down application menu

 

from my POV a much easier solution

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
Bluenoser
Posts: 313
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Beta 3: Preventing Duplicate SettingsActionItem

@ekke

 

  A sheet is easier, but does not match the UI guidelines for settings.

 

http://docs.blackberry.com/en/developers/deliverables/41577/settings.jsp

Developer
ekke
Posts: 1,568
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Beta 3: Preventing Duplicate SettingsActionItem

you're right

 

(my settings have to be stored in a cloud service, so I used the sheet there to have explicite save / cancel)

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
New Developer
MichaelBuc
Posts: 12
Registered: ‎03-09-2011
My Device: Z10

Re: Beta 3: Preventing Duplicate SettingsActionItem

Hi,

Quite old thread but anyhow I found this to be the easiest solution

Application.menuEnabled = false;

 

 settingsAction: SettingsActionItem {
            onTriggered: {
                var settingsPage = goToSettingsPage.createObject()
                mainMenuPage.push(settingsPage)
                Application.menuEnabled = false;
            }
            attachedObjects: ComponentDefinition {
                id: goToSettingsPage
                source: "settings.qml"
            }
...
 onPopTransitionEnded: {
        Application.menuEnabled = true;
        page.destroy();
    }

 See you,

 

Michael

The famous Movie Quiz:
http://appworld.blackberry.com/webstore/content/34285892/?lang=en&countrycode=DE