You Are Here:

Community: Wiki

This page was last modified on 13 May 2009, at 09:27.

Update dialog cba

From Forum Nokia Wiki


The following example shows how to update the CBA of a custom dialog depending upon a given conditon. There are lot of times when we want to bring up a dialog and then change the CBA depending upon certain conditons, i.e. text inputted in the dialog/state of the application etc.

Header file required:

#include <aknquerydialog.h>

No rss is provided as the standard rss for a query dialog would work fine.

Add following lines in .h file.

class CYourDialog : public CAknTextQueryDialog
{
public:
 
static CYourDialog* NewL(
TDes& aText, TTone aTone = ENoTone)
{
CYourDialog* self =
new (ELeave) CYourDialog(aText, aTone);
return self;
}
 
protected:
 
CYourDialog(TDes& aText, const TTone& aTone):CAknTextQueryDialog(aText, aTone)
{
// No implementation required
}
 
protected: // from CAknTextQueryDialog
 
void UpdateLeftSoftKeyL(); //This function would be called everytime something is entered in the dialog
};

Add following lines in .cpp file.

// In your container/view class
TBuf<20> myText;
iYourDialog = CYourDialog::NewL(myText);
iYourDialog->PrepareLC(/*Resource def from rssi file*/);
iYourDialog->RunLD();
 
 
/**
* Over-ridden function from CAknTextQueryDialog, allows us to change the
* text of the LSK depending on some condition
*/

void CYourDialog::UpdateLeftSoftKeyL()
{
CEikButtonGroupContainer& cba = ButtonGroupContainer();
cba.SetCommandSetL(R_AVKON_SOFTKEYS_OK_CANCEL);
TInt posOk = cba.PositionById(EAknSoftkeyOk);
HBufC* textResource = NULL;
 
MakeLeftSoftkeyVisible(ETrue); //Even if there is nothing, shows the LSK
if(CheckIfEntryTextOk()) // in case something is entered
{
if(/*Your Condition 1*/)
{
// My Condition 1 met, leme update
textResource = StringLoader::LoadLC(/*Text resource from rss*/);
cba.SetCommandL(posOk, EAknSoftkeyOk, *textResource);
}
else if(/*Your Condition 2*/)
{
// My Condition 2 met, leme update
textResource = StringLoader::LoadLC(/*Text resource from rss*/);
cba.SetCommandL(posOk, EAknSoftkeyOk, *textResource);
}
}
else
{
// No text is there, lets put something else
textResource = StringLoader::LoadLC(/*Text resource from rss*/);
cba.SetCommandL(posOk, EAknSoftkeyOk, *textResource);
}
if(textResource != NULL)
{
CleanupStack::PopAndDestroy( textResource );
cba.DrawNow();
}
}

Now with this code, your RSK would be changed to show something else depending on what you want instead of the simple Ok which could be confusing to the user on conditional states in your application.

Added by - Mayank on 12/05/2009

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fE25E455E25A6E2582E25E454E25BE44E2595E25E455E259CE25A8E25E456E2594E25B6E25E454E25BBE25B6E25E457E25AE45E25B1E25E455E2588E259BE25E455E25BBE25BAE25E457E259FE25AE44E25E454E25BFE25A1X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ