Hi,
In my module i have two views
ContactsSetting view
Photosetting view
these two views can be launched from any other views.
Now i want to implement back key funtionality to this views. when i press back key option in this current view it should go back to previous view from where this setting view was called. Can anyone please tell me how to implement this??
hi nagesh,
Before going to next view u just implement this and u can set command as per ur needy.
CEikButtonGroupContainer* cba1=CEikButtonGroupContainer::Current();
cba1->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_BACK);
cba1->DrawNow();
Thanks
mitu
Hi,
This will change the options sofkeys which ever way needed. but how this will handle back key. when you press back key you would't be knowing the view from which we have come from.Does this CEikButtonGroupContainer::Current(); map the back key to the previous view. pls explain.
Hi nagesh,
In HandleCommandL method u take this case
case EAknSoftkeyBack:
in this method u make comparision .if view2 then go to view1(when click back option in view2) and also vice versa.while creating view u should take any flag and which ensure to comparison between views.
Thanks
mitu
CMyAppUI { // create views here, and store pointers into array iViews }
void HandleCommandL(TInt aCommand) { ... switch (aCommand) { case EAknSoftkeyExit: { Exit(); } case EAknSoftkeyBack: { // use SwitchViewL here to navigate between your views. You can use // CurrentView() and/or iPreviousView } .... }
Forum posts: 55
hi nagesh,
Before going to next view u just implement this and u can set command as per ur needy.
CEikButtonGroupContainer* cba1=CEikButtonGroupContainer::Current();
cba1->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_BACK);
cba1->DrawNow();
Thanks
mitu
Forum posts: 2
Hi,
This will change the options sofkeys which ever way needed. but how this will handle back key. when you press back key you would't be knowing the view from which we have come from.Does this CEikButtonGroupContainer::Current(); map the back key to the previous view. pls explain.
regards
Nagesh N
Forum posts: 55
Hi nagesh,
In HandleCommandL method u take this case
case EAknSoftkeyBack:
in this method u make comparision .if view2 then go to view1(when click back option in view2) and also vice versa.while creating view u should take any flag and which ensure to comparison between views.
Thanks
mitu
Forum posts: 8
Make CMyViewBase, e.g.
class CMyViewBase : public CCoeControl, public MCoeView {
...
TVwsViewId ViewId() const
{
return TVwsViewId(SbiUid, ViewUid());
}
virtual TUid ViewUid() const = 0; // implemened in derived class
...
}
Then all your views (ContactsSetting, PhotoSetting) will be inhertited from CMyViewBase.
In Your CAknAppaUI use array of all created views (fill this array e.g. in ctor of CAknAppUI)
class CMyAppUI ... {
CMyViewBase* iViews[MAX_VIEWS];
CMyViewBase* iPreviousView;
CMyAppUI {
// create views here, and store pointers into array iViews
}
void HandleCommandL(TInt aCommand) {
...
switch (aCommand) {
case EAknSoftkeyExit: {
Exit();
}
case EAknSoftkeyBack: {
// use SwitchViewL here to navigate between your views. You can use
// CurrentView() and/or iPreviousView
}
....
}
void SwitchViewL(const TUid& aTargetViewId, CMyViewBase& aTargetView) {
if ( CurrentView()!= &aTargetView) {
TVwsViewId id(MyUid, aTargetViewId);
ActivateViewL(id);
}
}
CMyViewBase* CurrentView() {
TVwsViewId id;
TInt err = GetActiveViewId(id);
if ( err == KErrNone) {
for (TInt i = 0; i < MAX_VIEWS; i++) {
if ( iViews[i] && id == iViews[i]->ViewId()) {
return iViews[i];
}
}
}
return NULL;
}
}
Jozef PrÃdavok - http://pridavok.sk/
Mothiva, s.r.o - http://mothiva.com/