Titanium JIRA Archive
Alloy (ALOY)

[ALOY-533] Better error message when defining menu on a lightweight window

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-07-19T19:03:56.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.2.0, 2013 Sprint 15
ComponentsRuntime, XML
Labelsqe-testadded
ReporterJeff English
AssigneeTony Lukasavage
Created2013-02-22T16:10:52.000+0000
Updated2013-07-24T00:07:04.000+0000

Description

If you define a lightweight window that includes the definition of a 'menu' and attempt to 'open' it, at runtime it will display an obscure error message -- "Uncaught TypeError: Cannot call method 'extend' of undefined" (see attached screen shot) It turns out that this is due to the fact that a menu can only be defined on a heavyweight window. Changing the window definition to be a heavyweight window resolves the issue. It would be helpful to have the error message indicate that you are attempting to set a menu on a lightweight window. Reproduction Steps: 1. Create a new Alloy project (use the default 'simple' template) 2. Edit the index.xml file 3. Add a menu to the window definition 4. Run as an Android application (simulator or device) You should get the attached error dialog 5. Add the 'navBarHidden=true' attribute to the 'Window' element in index.xml 6. Run as an Android application (simulator or device) The application should run fine and you should see the menu when you press the menu button.

Attachments

FileDateSize
Screen Shot 2013-02-22 at 10.03.29 AM.png2013-02-22T16:10:52.000+000027187

Comments

  1. Tony Lukasavage 2013-07-19

    PR: https://github.com/appcelerator/alloy/pull/189 test app: https://github.com/appcelerator/alloy/tree/master/test/apps/ui/android_menu This only needs to be tested functionally on Android. Follow these steps.

    Run the test app on Android

    on Window 1, press the menu button to open the Android Menu. You should see a "help" and "home" button, like in the first attached screenshot.

    Click the "home" button, which should open window 2.

    Click the menu button again, which should open the a menu with different menu buttons (wrench and arrow), pictured in the second screenshot

    after you have confirmed that you are getting 2 separate menus, go back to the app code and try this now:

    Open "app/styles/win2.tss" and remove "modal: false". This will make the window 2 a lightweight window.

    Run the app again

    Follow steps 2-3 from the first section

    Check the console log and make sure you see the warning in the 3rd screenshot

    Click the menu button. It should be the same menu as the first window since window 2 is lightweight and cannot hold its own menu.

  2. Federico Casali 2013-07-23

    Verified as fixed. Environment: Titanium SDK 3.1.2.v20130718094558 Alloy 1.2.0 Appcelerator Studio 3.1.1.201306131423 LiveView 0.1.28 Android device 4.2.2 Closing.

JSON Source