Creating a pop-up window

37 posts / 0 new
Last post
Vasily Zakharov
Jolaf's picture
Offline
Mobile Conjurer
Joined: 6 Apr 2010
Posts:
Creating a pop-up window

I'd like to create a pop-up window occupying only part of the screen, with parts of main window visible.

Using a separate Screen only allows overdrawing the whole screen, which is not what I need.

I tried using showOverlay(), but it looks undocumented, and works terribly slow - 1-2 seconds on emulator and 5-6 seconds on the phone (Sony Ericsson C702). Is it normal or I'm doing something wrong?

Are there any other ways to achieve my goal?

I'm using MoSync 2.3B r767.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Somebody else (I've forgotten who) needed to do this as well. Your two options are to use showOverlay(), but as you say it may not be all there yet. The second option is to create a new screen with a transparent background with your popup in it. This is probably easier to do and more reliable. You can use the same class for every popup, and change the message/buttons in it. If I get time later I'll put something together for you about it.

Vasily Zakharov
Jolaf's picture
Offline
Mobile Conjurer
Joined: 6 Apr 2010
Posts:

rival, thanks!

I always thought that if I show() a new schreen, an older one is hide()en. Isn't it true?

Moreover, the main screen that I want to be partially visible beyond the popup, contains dynamic content, that should be updated (timerListener does that) during the popup is open. Is it possible if the popup is a screen?

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Jolaf, I don't think it will be possible to do what you want with a screen then. Do you want something like toast popping up with notifications? It's going to be fairly complex to do in MAUI. The way I would approach it is probably to create a new Screen class (inheriting from the old one) which also has the code to handle the popup. Then use this class as the base for all of your screens. Let me think about it.

Vasily Zakharov
Jolaf's picture
Offline
Mobile Conjurer
Joined: 6 Apr 2010
Posts:

Yes, that's what I'd like to have. Thanks, I'll go read into Screen.

poocka
poocka's picture
Offline
Joined: 6 Apr 2010
Posts:

Also try to create Screen Layout with 3x3 dimension. then use central cell as popup.
I do not know if it is able to add Widget into layout to desired position, but you may create an empty widget just to fill layout placeholders that you wish to be transparent.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Hello Everyone,

I have a button on screen that downloads file from the internet. I want to show a screen when the download starts and hide it when the download finishes.
i created a screen and i show in when i click the button that starts the download and it shows i try to go back using APPCONTROLLER->back(); but the previous page doesnot show
here is the class i use for downloading the file.

DownloadXML::~DownloadXML()
{
}
void DownloadXML::dl(String& url, String& storeName)
{

	mStoreName=storeName;
	mUrl=url;
	Downloader* idl = new Downloader();
	idl->addDownloadListener(this);
	MAHandle docResource = maCreatePlaceholder();
	idl-> beginDownloading(mUrl.c_str(), docResource);

}

void DownloadXML::finishedDownloading(Downloader *dl, MAHandle data)
{
	StoreHandler::saveToStore(mStoreName.c_str(),data);
	lprintfln("finish download");
	APPCONTROLLER->back();// nothing happens
	}
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

How are you showing the DownloadXML screen? If you're not using APPCONTROLLER->show() then you won't be able to use ->back()

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

I use it in another screen called MenuScreen that has a button that downloads xml file and saves it to a store and then calls
APPCONTROLLER->show("PopUpScreen") and here the PopUpScreen opens . What I do after that is calling APPCONTROLLER->back() in the function finishedDownloading() in DownloadXML class the function works fine and lprintfln("finish download"); output the text , but APPCONTROLLER->back() does nothing.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

You're going to have to add some debug in back() to list through the history - you need to find what it thinks is the previous screen and what it is trying to show.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Hello Sam,
I found somthing strange while testing. First on the PointeRrelese event in POPUP screen I call APPCONTROLLER->back(), and I removed APPCONTROLLER->back() that is called when the download is finished, so when I click on the POPUP page I go back to the MainMenu page. But when APPCONTROLLER->back() is called after the download is finished nothing happens, besides when I click on the POPUP screen the the pointerrelese event does nothing.
Another thing. I found in my code that the lines of code after the download command are executed before the download is finished:
below is the code I use when I click on the download button

                               
                                APPCONTROLLER->show("UpdatingScrn");
		String dllinke="xml link";
		String storee="a.xml";
		DownloadXML* ud=new DownloadXML();
		ud->dl(dllinke,storee);//download starts here
		lprintfln("finish download");// this text is printed before the download starts
		APPCONTROLLER->back();
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Yeah, the download is asynchronous - it runs in the background and you can carry on doing whatever you were doing until its finished. I can't remember how the version you've got there works, but the new version (coming soon folks) calls back to the requesting class when their download has finished.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Hello Sam,
I checked the back function again and the values of the previous screen and the next screen is set right, but the problem happens in the ScreenTransition class in the function below as when APPCONTROLLER->back() is called after the download is finished, (gScreen !=0) is = true and return in called. But normally the function continues the execution of the below line of codes. I just wanna know what gScreen represents??

 void ScreenTransition::makeTransition(MAUI::Screen* fromScreen, MAUI::Screen* toScreen, int direction, int duration, TransitionType type)
       {
          if (gScreen != Innocent
          {
        	  lprintfln("will return");
            return;
          }
          lprintfln("will cont");
          gScreen = new MAUI::Screen();
          gWidget = new ScreenTransition();
          gScreen->setMain(gWidget);
          gWidget->fromMainWidget = fromScreen->getMain();
          gWidget->toScreen = toScreen;
          gWidget->toMainWidget = toScreen->getMain();
          gWidget->direction = direction;
          gWidget->duration = duration;
          gWidget->start_time = maGetMilliSecondCount();
          gWidget->updateAlpha(gWidget->start_time);
          currentType = type;

          // This will tell the widget to fix stuff before being drawn
          gWidget->toMainWidget->update();

          gScreen->show();
          MAUtil::Environment::getEnvironment().addTimer(gWidget, 20, -1);
       }
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

gScreen is a new instance of Screen which is only in existence for the transition. It displays the two main widgets (from the two screens it is animating), and it is destroyed at the end of the transition.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

but when i out put the value of gscreen when I call APPController->back(), on the popup screen it gives me big number of digits 76227 for example thats why it enters this if statment

if (gScreen != 0 )
{
lprintfln("will return");
return;
}
,, while it always outputs 0 when back() is called on other screens. Besides, I could not figure out where it gets that dummy number

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Hey Sam,
Might the problem happen from calling APPCONTROLLER->back() from another class other than the class of the screen shown??

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

No, APPCONTROLLER is a macro which gets the singleton instance of the AppController class. This means that you can call it from anywhere.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Hey Sam am still stuck in the same problem as APPCONTROLLER->back() does not work in the case mentioned before. Do u mind if i send you the project ??

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

OK. Zip (not rar!) and email it to me at samuel.pickard AT mosync.com

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Also (important!) do not zip up the Output and FinalOutput folders - I just need the source code.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

I'm also out this afternoon, so I won't be able to look at it until tomorrow morning.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

ok Sam I will send it to you
thank you

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

OK, I'm going to need some instructions. I've copied the xml files to the stores (as if they had downloaded), and I can browse through your XML, but I've not got a popup menu anywhere and the back button appears to work fine. What do I need to press?

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

At the main menu screen at the softkeybar there is update, when you click it downloading should start and APPCONTROL->show("Updatinscreen") opens the updating screen (In DownloadXML.cpp) and when the download finish APPCONTROL->back() is called to get back to menu, but the screen doesnot get back to the menu, all in the DownloadXML.cpp. this process works when the download of xml happens using the download listeners as I am using a url onn local network to download the xml files, so i donot know if you will be able to test the download effect.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

OK.  I have some questions.  This is from MenuScreen.cpp

			evtLink="http://10.0.0.71/msamir/a.xml";
			comLink ="http://10.0.0.71/msamir/temp.xml";
			evtStore="a.xml";
			comStore="temp.xml";
			DownloadXML* evtDld=new DownloadXML(evtLink,evtStore);
			DownloadXML* comDld=new DownloadXML(comLink,comStore);
			int size=(int)mScreens.size();
			APPCONTROLLER->deleteScreen(size);
			mScreens.clear();

1.  The DownloadXML class calls APPCONTROLLER->back(), but you've got *two* DownloadXML classes - do you want to go back two screens?

2.  You are creating new instances of DownloadXML here - where are they being deleted?  If you don't call delete evtDld and delete comDld then you can't have their memory back.

3. At the bottom of this code, you are deleting the current screen.  How can the transition show the parts of this screen it needs to if you've deleted it?

I think your problems are related to at least items 1 and 3.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

1st point, I tried it using only 1 download and I had the same problem, besides I modified the appcontroller class to show only the page once and thats by checking the previous stored page, so i donot think thats the problem.

2nd point, yeah i still donot know where to delete those items as the destructor is called only when the application exits, i tried to use delete after the download finishes but i get errors. (hope to get help with that)

3rd point , if you mean these lines of code
APPCONTROLLER->deleteScreen(size);
mScreens.clear();
I think they have nothing to do with the problem as i had the problem before adding them. besides, I added deleteScreen(size) function in the APPCONTROL class as it only checks if Rssindex pages found and deletes them and mScreens.clear(); is a map that contains indexes for RSSindex screen. I added them coz i wanted to delete the RSSindex screens i have when i do the update, so to be built again with the new data, besides i tested them and they work fine, but u can comment them if you want to.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Another thing i want to add, if u comment the APPCONTROLLER->back() called in finished download and used the one in pointer listener by clicking on the screen that appears, it goes back normally. But if you donot comment it and tried to click on the screen the pointersevent doesnt listen.

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Right, I'm emailing you your project back, but the problem is definitely that you're using two DownloadXML, each of which shows the Updating screen and then calls back.

The history is a list of screens in reverse order that they've been shown. It won't add to the history any screen which is already at the top of the stack, or else your use will press a back button and get the same screen they were looking at, which doesn't make any sense.

I changed it to just do one download and everything works perfectly. I know your next question is 'how do I do two downloads then?', and the answer is to refactor your download code. You need to think about the separation of concerns in your design.  Fundamentally, the problem isn't with the APPCONTROLLER->back() function, becuase we don't want a user to move back and be faced with the same screen, but with the design of DownloadXML, which has two concerns, managing a download and updating the UI.  Separate these resposibilities out, and make each class responsible for one clearly defined task.  I can help you with this if you need it.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

First I want to thank you for your effort.
but did it works fine only when you did one download without changing anything, coz i remember i tried that many times and i got the same problem. Besides even with two download why the APPCONTROLLER->back() works fine in the pointerlistener event??!!.

About the separaction of concerns that is really a problem with me dowing 2 download and i wanted a better design for that, so for sure i need some help with it.

Another thing there is a problem with the kineticlistbox movement is it ok to discuss it in this forume??

Finally I really want to thank you for your effort and time, and am waing to get the project to see how the problem is fixed

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

No problem. There are a *lot* of problems with KineticListBox - it is a widget which was knocked up in a hurry by someone on the forum, and isn't an *official* MoSync widget or anything. I've got a new version ready for release soon, but it requires a whole new UI library (instead of MAUI). I've enclosed my most recent MAUI version (from Feb 2011) which probably has a lot of bug fixes in, so try that first.

AttachmentSize
KineticListBox.zip 8.77 KB
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Also, if you change topic, can you create a new thread? We seem to have moved a long way from popup boxes.

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

I raised that issue in a thred before here is the link for the thread
http://www.mosync.com/node/6662

blanco edwardo
ykuoles's picture
Offline
Mobile Wizard
Joined: 9 Jun 2011
Posts:

Hello Sam,

I still have the same problem with APPCONTROLLER->back()
would that be the emulator's or mosync's problem??

interdpth
interdpth's picture
Offline
Joined: 13 Sep 2011
Posts:

Sorry to bump an old thread, but has anyone found a solution to this?

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Ahh, which problem are you referring to? KineticListBox? If so, you either need to use the NativeUI ListView control, or replace MAUI with the AppMancer AMUI library and use the ListBox widget in that. APPCONTROLLER hasn't been developed for a long time. It has been replaced by several different classes in AppMancer - ScreenWarehouse, StackScreen and a few others.

interdpth
interdpth's picture
Offline
Joined: 13 Sep 2011
Posts:

No, sorry. I am referring to a "toast" like window, once I have more than two screens I can't seem to make a third. :/

interdpth
interdpth's picture
Offline
Joined: 13 Sep 2011
Posts:

Well, I can make the third, it's code runs, but it won't display unless I hide the second window