×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    27

    How to hide CBA's ?

    HI !

    I want to use the CBA-buttons ( cba=R_AVKON_SOFTKEYS_OK_CANCEL ), but I don't know how ;-(
    I read different threads and in some postings people sugguest to use the following code:


    // Code
    CEikButtonGroupContainer* pCba = CEikButtonGroupContainer::Current();
    pCba->MakeVisible(EFalse);

    The OK / Cancel is not showing, but the following CBA is showing: " Options ^ Exit "

    I didn't define this CBA in my code ...

    Is there any developer, who can explain me that behavior and ( more important ) say me, how to hide the OK / Cancel CBA-Define
    correctly ?

    Thanks . . .

    Greeting
    IngeS

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    this behavoiur looks quite strange, but it is normal belive me.

    You can use CBA buttons in two ways. If your application has only one view with one defined and displayde button array(called CBA), this piece of code is enough:

    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
    cba->MakeVisible(EFalse);

    You must of course redraw the screen to fill "bigger" screen.
    Everything is OK.

    But in some situations this technique fails.

    The button container can hold many CBAs, but only one button array is currently displayed. When you have a view with CBA and you (for example) use a dialog with hidden buttons and in the dialog method PostLayoutDynInitL() you wil using previous technique to hide CBA buttons you will be probably surprised that ofter pressing button menu pane from underlaying view will be displayed. It looks like a bug, but it is correct. The framework just pass the key commend to first CBA which is "visible", even if is under your dialog and not diplayed on the screen. You have two possiblities how to solve such problem. The straight one is to call MaheVisible(EFalse) also on view CBA. But basically you dont know if there are not any other CBAs. The better solution is here:

    // get current CBAs
    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();

    // get position of first button in CBA
    TInt posOptions = cba->PositionById(EAknSoftkeyOptions);
    cba->UpdateCommandObserverL(posOptions,*this);
    // get position of second button in CBA
    TInt posBack = cba->PositionById(EAknSoftkeyBack);
    cba->UpdateCommandObserverL(posBack,*this);

    You obtain a pointer to current CBA, get the button position (by calling PositionById(), which has Command ID as a parameter. Command ID is specified in resource CBA in .rss file, I use predefined AVKON CBA, so EAknSoftkeyOptions and EAknSoftkeyBack I found in avkon.hrh file). After having position you call UpdateCommandObserverL() method. The second parameter points to implemented mixin class MEikCommandObserver. It has method ProcessCommandL() which will consume the pressing on cba. Now you can call MakeVisible(EFalse) on dialog CBA. The menu pane of underlying view will not show.


    Summarize
    --------------
    If you want to hide a current CBA and there is another second CBA you must provide the new command observer to such CBA and consume its commands.

    Bye
    STeN

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    27

    Errors . . .

    HI !

    First of all, a big THANK YOU to you STeN for reply.
    But I have Problems to understand the solution. You wrote, that there is showing the 2th CBA define of the next view.
    You have right, if you guess, that I have different views, but the 2th view has the same CBA define ( cba=R_AVKON_SOFTKEYS_OK_CANCEL ),
    so where is the OPTIONS/BACK-Define from ?

    BTW, I tried your code and it doesn't work - surely my fault. The ConstructL - Func of my Container is the following now:


    void CTrousersContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    // get current CBAs
    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();

    // get position of first button in CBA
    TInt posOptions = cba->PositionById(EAknSoftkeyOk);
    cba->UpdateCommandObserverL(posOptions,*this);

    // get position of second button in CBA
    TInt posBack = cba->PositionById(EAknSoftkeyCancel);
    cba->UpdateCommandObserverL(posBack,*this);

    SetRect(aRect);
    ActivateL();

    }

    and the ProcessCommand:



    void CTrousersContainer::ProcessCommandL(TInt iCommand)
    {
    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
    cba->MakeVisible(EFalse);

    DrawNow();
    }


    First, I see the "OK CANCEL", after click on ok, I see "OPTIONS ^ BACK". Where is my mistake ?


    Greetings
    IngeS

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    22

    Re: How to hide CBA's ?

    Hi, I use
    CEikButtonGroupContainer* iCba
    as menu in my videoplayer, when i go to Full Screen view i wanna hide
    and deactivate it.
    I am trying to do it via iCba->MakeVisible(EFalse) - and, indeed, it
    hides the menu form the view.

    BUT - its still reacts to right/left menu button pressed in some wierd
    maner. it doesnt produces the commands assigned to it (before hiding).
    i am failed to figure out what commands it produce and where to catch
    it.

    as i know iCba->MakeVisible(EFalse) should substitute my cba with some
    NULL cba, but it doesn seems that way.

    any ideas?

    the button pressed is also didnt catch in OfferKeyEventL of the control. tried to catch it that way:

    if (aType==EEventKeyDown && (aKeyEvent.iScanCode == EStdKeyDevice0 || aKeyEvent.iScanCode == EStdKeyDevice1))

    {

    DO something

    }

  5. #5
    Registered User
    Join Date
    Oct 2006
    Location
    philippines
    Posts
    40

    Re: How to hide CBA's ?

    find the buttons = R_AVKON_SOFTKEYS_OPTIONS_EXIT in your rss file and replace it with R_AVKON_SOFTKEYS_OK_CANCEL.
    misfit - a square peg in a round hole.

  6. #6
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: How to hide CBA's ?

    you can also change the text of the cba button by
    Cba()->SetCommandL (EAknSoftkeyBack, _L("Hide"));
    Cba()->DrawNow();

    write it in DoActivateL if you hav eview container architecture.
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  7. #7
    Registered User
    Join Date
    Oct 2006
    Location
    philippines
    Posts
    40

    Re: How to hide CBA's ?

    i tried your suggestion, it has an access violation something in the cba declaration line. And i cant understand why. I'm just trying to make a pop-up menu and change the softkey labels....out of curiosity...

    ------------------------------------------

    iMenuBar = ((CAknView*)iParent)->MenuBar();
    iMenuBar->SetMenuTitleResourceId(R_PRADDRESS_LIST_OPTIONS_MENU);
    ---------------------------------------------------
    CEikButtonGroupContainer *cba = iAppUi->Cba(); <------ACCESS VIOLATION! CAN ANYONE POINT OUT?
    -------------------------------------------------------
    cba->SetCommandL(EAknSoftkeySelect, _L("vSelect"));
    cba->SetCommandL(EAknSoftkeyCancel, _L("vCancel"));
    misfit - a square peg in a round hole.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Location
    philippines
    Posts
    40

    Re: How to hide CBA's ?

    this is in the container class by the way. "iAppUi" is a pointer to the view class..
    misfit - a square peg in a round hole.

  9. #9
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: How to hide CBA's ?

    do it like this

    void C3MainView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,const TDesC8& /*aCustomMessage*/)
    {
    iView = new(ELeave) C3MainContainer;
    iView->SetMopParent(this);

    TRect cr = ClientRect();
    if (cr.iTl.iY == Kqpn_height_status_pane_idle)
    {
    cr.iTl.iY = Kqpn_height_status_pane_usual;
    }
    iView->ConstructL(cr);
    AppUi()->AddToStackL(*this,iView);
    Cba()->SetCommandL (EAknSoftkeyBack, _L("Hide"));
    Cba()->DrawNow();
    }
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×