Titanium JIRA Archive
Alloy (ALOY)

[ALOY-720] Allow Widgets as child of Menu tag

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-20T02:08:44.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.2.0, 2013 Sprint 15
ComponentsWidgets, XML
Labelsqe-testadded
ReporterTiman Rebel
AssigneeTony Lukasavage
Created2013-06-24T12:50:30.000+0000
Updated2014-02-04T20:21:49.000+0000

Description

We use one codebase for our iOS and Android app and like to reuse as much code as possible. It is not possible however to use a Widget inside a tag, but you can inside a . It would really simplify our lives if we could use Widgets and generalize our MenuBar buttons across platforms index.xml
<RightNavButton>
    <Widget src="sc.MenuBarButton" title="Save" onClick="onSave" />
</RightNavButton>
		
<Menu>
    <Widget src="sc.MenuBarButton" title="Save" onClick="onSave" />
</Menu>
widget.xml
<Alloy>
	<Button id="button" onClick="onClick" platform="ios" />
	<MenuItem id="buton" onClick="onClick" platform="android" />
</Alloy>
Error:
[ERROR] :  Invalid child type under <Menu>: Alloy.Widget
[ERROR] :  <Menu> must have only <MenuItem> elements as children
[ERROR] :  Alloy compiler failed

Comments

  1. Tony Lukasavage 2013-07-20

    PR: https://github.com/appcelerator/alloy/pull/191 test app: https://github.com/appcelerator/alloy/tree/master/test/apps/testing/ALOY-720 This should be tested on at least iOS and Android.

    iOS

    Run the app

    Click the rightNavButton in the nav bar

    Confirm that an alert dialog with the word "save" pops up

    android

    Run the app

    Click the menu button

    Click the resulting menu button labeled "android"

    Confirm that an alert dialog with the word "save" pops up

  2. Federico Casali 2013-08-02

    Verified working as expected. Titanium SDK 3.1.2.v20130730133101 Alloy 1.2.0-alpha2 Appcelerator Studio 3.1.2.201307261628 CLI 3.1.1 Node 0.8.22 Closing.
  3. Federico Casali 2014-02-04

    Test case for iOS has to be updated as Titanium.UI.iPhone.NavigationGroup is no longer supported. Following code works:
       <Alloy>
       		<NavigationWindow platform="ios">
       			<Window>
       				<RightNavButton>
       					<Widget src="alloy.button" title="ios" onClick="doSave"/>
       				</RightNavButton>
       			</Window>
       		</NavigationWindow>
       		<Menu platform="android">
       			<Widget src="alloy.button" title="android" onClick="doSave"/>
       		</Menu>
       
       		<Label id="info"/>
       </Alloy>
       

JSON Source