Titanium

[ALOY-1176] Compilation Error when adding a SearchView as a child of MenuItem ActionView

GitHub Issuen/a
TypeBug
PriorityNone
StatusResolved
ResolutionDuplicate
Resolution Date2014-10-22T14:03:08.000+0000
Affected Version/sAlloy 1.6.0
Fix Version/sn/a
ComponentsXML
Labelsn/a
ReporterBenjamin Hatfield
AssigneeTim Poulsen
Created2014-10-21T21:29:19.000+0000
Updated2014-10-22T14:03:08.000+0000

Description

DESCRIPTION: Alloy throws a compilation error when declaring a SearchView as a child of MenuItem ActionView in XML markup. REPRODUCTION: Run the code below in the Genymotion emulator. index.xml:
<Alloy>
    <Window id="win">
        <Menu>
            <MenuItem>
                <ActionView>
                	<SearchView hintText="Type Something"/>
                </ActionView>
            </MenuItem>
        </Menu>            
    </Window>
</Alloy>
index.js:
$.win.open();
RESULTS: Alloy throws a compilation error:
[WARN] :   ('You attempted to attach an Android Menu to a lightweight Window');
[WARN] :   ('or other UI component which does not have an Android activity.');
[WARN] :   ('Android Menus can only be opened on TabGroups and heavyweight Windows.');
[ERROR] :  
[ERROR] :  (/usr/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:189:18)
[ERROR] :  (/usr/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:197:11)
[ERROR] :  (/usr/local/lib/node_modules/alloy/node_modules/uglify-js/lib/parse.js:664:9)
[ERROR] :  Alloy compiler failed
[ERROR] Application Installer abnormal process termination. Process exit value was 1
Classic test:
var win = Ti.UI.createWindow();
win.addEventListener("open", function() {
    win.activity.onCreateOptionsMenu = function(e) {
        var item, menu;
        menu = e.menu;
        menu.clear();
        item = menu.add({
            title : "Search",
            showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS,
            actionView: Ti.UI.Android.createSearchView({ hintText: "Type Somethings" })
        });
    };
});

win.open();

Comments

  1. Federico Casali 2014-10-21
  2. Benjamin Hatfield 2014-10-21 Oops. Seems to be a namespace issue. Adding the ns attribute allows the Alloy compilation process to succeed. I'll open up an improvement ticket instead to have SearchView implicitly namespaced to "Ti.UI.Android" like some of the iOS components.
       <Alloy>
           <Window>
               <Menu>
                   <MenuItem>
                       <ActionView>
                           <SearchView ns="Ti.UI.Android" hintText="Type Something"/>
                       </ActionView>
                   </MenuItem>
               </Menu>            
           </Window>
       </Alloy>
       
  3. Tim Poulsen 2014-10-22 I'm going to close this and fix it via ALOY-1177.

JSON Source