View Architecture activates wrong view?
| Sun, 2003-12-14 07:05 | |
|
Hi, I'm using the view architecture and a call to 'ActivateViewL' results in the wrong view being displayed. I know that each view returns the correct id and that I'm activating the write view because I've traced the execution through with the debugger.
I declare my views like this: Code: iView1 = View1::NewL(ApplicationRect()); RegisterViewL((MCoeView&)*iView1 ); AddToStackL((MCoeView&)*iView1 , (CCoeControl*)iView1 ); iView2 = View2::NewL(ApplicationRect()); RegisterViewL((MCoeView&)*iView2); AddToStackL((MCoeView&)*iView2, (CCoeControl*)iView2); iView3 = View3::NewL(ClientRect(), this); RegisterViewL((MCoeView&)*iView3); AddToStackL((MCoeView&)*iView3, (CCoeControl*)iView3); iView4= View4::NewL(ClientRect(), this); RegisterViewL((MCoeView&)*iView4); AddToStackL((MCoeView&)*iView4, (CCoeControl*)iView4); iView5= View5::NewL(ClientRect(), this); RegisterViewL((MCoeView&)*iView5); AddToStackL((MCoeView&)*iView5, (CCoeControl*)iView5); The view ID's are defined in the following manner: Code: static const TUid KUidView1 = { 0x100000E1 }; static const TUid KUidView2 = { 0x100000E2 }; static const TUid KUidView3 = { 0x100000E3 }; static const TUid KUidView4 = { 0x100000E4 }; static const TUid KUidView5 = { 0x100000E5 }; Some of my views are activated in the method 'HandleForegroundEventL', and some are activated else where in my appui class, is this a problem. Thanks, any help would be appreciated. |
|






Forum posts: 16
Second, listen for the view activated event. And when it happens, on the window call SetPosition(0) to ensure it is on top.
Problem solved?
Forum posts: 16
In my docs SetPosition is listed as 'void SetPosition(const TPoint& aPosition)', how would calling this method ensure it is on top. It just sets the point at which the control is displayed in the window it is owned by.
What happens if RegisterViewL leaves, and you DeregisterView in the destructor?
TInt RegErr;
iView1 = View1::NewL(ApplicationRect());
TRAP(RegErr,RegisterViewL(*iView1));
if(KErrNone != RegErr)
{
delete iView1;
iView1 = NULL;
User::Leave(RegErr);
}
AddToStackL(*iView1,iView1);
.. repeat for each view ..
So, to trace the wrong view thing; what does the View1::ViewId() look like?
Forum posts: 53
The first time your app is activated you get a notification in this function and probably you reactivate the very same view.
this function is triggered also when a dialog that was over your view appears or is dismissed ... clearly you don't want to reactivate the view because of it.
You have to be very carefully when you implements HandleForegroundEventL.