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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
Zmey
Posts: 886
Registered: ‎12-18-2012

Re: Overriding peek for customcontrol

[ Edited ]

All GUI controls inherit from BaseObject which has parent property. A possible solution is to find NavigationPane by iterating CustomControl's parents. This way it will work even when the control is deep in hierarchy of objects.

 

Untested code:

 

NavigationPane *MyControl::navigationPane()
{
  QObject *p = parent();
  while (p)
  {
    NavigationPane *pane = qobject_cast<NavigationPane *>(p);
    if (pane != NULL)
      return pane;
    p = p->parent();
  }
  return NULL;
}

...

NavigationPane *pane = navigationPane();
if (pane)
  pane->setPeekEnabled(false);

upd: actually QObject has parent property, BaseObject just exposes it to QML. So it's ok to use QObject in code above.

 

Please use plain text.
Contributor
xtravanta
Posts: 45
Registered: ‎03-25-2011
My Carrier: KPN

Re: Overriding peek for customcontrol

What i did is creating a context class that has a static refrerence to the NavigationPane so that everywhere i am i can access the navpane by using Context::nav

so in youre case

main -> customcontrol1 -> customcontrol2 -> Context::nav->setPeekEnabled(bool);

Please use plain text.
Developer
BBSJdev
Posts: 641
Registered: ‎07-05-2012
My Carrier: Orange

Re: Overriding peek for customcontrol

[ Edited ]

Thanks guys appreciate the responses,

 

I think I'll give these a shot and see if any are suitable to my app.

 

Having tested this before Zmeys idea necessitates setting parent throughout the whole hierarchy and for my code at least with deeply hierarchical structures I often find parent is null at some point in the chain and therefore not guaranteed to work. At  least in my code that is.

 

Still a bug though. :smileywink:


---
If you've been helped give a like, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.