Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15621

Android: convertPointToView gives different results with SDK 3.1.3 compared to 3.0.2

    Details

    • Sprint:
      2014 Sprint 09 Tooling, 2014 Sprint 10 SDK

      Description

      Problem description

      User relies on convertPointToView to show a tooltip in a particular position, based on the user's click. However, using SDK 3.1.3, the coordinates given back by the function are negative, and the code is not working anymore.

      Sample code

      I reduced their code as much as possible. This sample shows the different values of 'y' when clicking the button using SDK 3.0.2 and SDK 3.1.3

      index.xml

      <Alloy>
      	<Window class="container">
      		<View id="cartWindow" class="container">
      			<View id="containerWindow" class="container">
      				<TableView id="table" zIndex="1" height="Ti.UI.SIZE" onClick="tableClick"></TableView>
      			</View>
      		</View>
      	</Window>
      </Alloy>
      

      pickerRow.xml

      <Alloy>
      	<TableViewRow id="rowcss" backgroundSelectedColor='transparent' selectedBackgroundColor = 'transparent'>
      		<Button id='btnAddToCart' left='0' backgroundColor='red' textAlign='left' width="55" height="20" />
      	</TableViewRow>
      </Alloy>
      

      index.tss

      ".container": {
      	backgroundColor:"white",
      	width: Ti.UI.SIZE,
      	height: Ti.UI.SIZE,
      	navBarHidden: true
      }
      

      index.js

      var item = Alloy.createController('pickerRow').getView();
      $.table.appendRow(item);
       
      var parentWin = $.index, button = '';
      function changeQuant(e) {
      	try {
      		button = e.source;
      		Ti.API.info("coordinates before convertPointToView :x" + e.x + " y" + e.y);
      		var pos = button.convertPointToView({
      			x : e.x,
      			y : e.y
      		}, parentWin);
      		Ti.API.info("********Position after convertPointToView**************" + JSON.stringify(pos));
      	} catch(e) {
      		Ti.API.info(e.message);
      	}
      };
       
      function tableClick(e) {
      	if (e.source.id == 'btnAddToCart') {
      		changeQuant(e);
      	}
      }
       
      $.index.open();
      

      Steps

      1. Build with SDK 3.0.2
      2. Open the app on Android
      3. Click the red button and see logs
      4. Repeat the steps using SDK 3.1.3

      *Result*

      The values for 'y' are very different; in particular, with 3.0.2 and my device I get around 600, while 3.1.3 gives a -500 (negative) for the same value.

      Work-around:

      The workaround is setting the height of the tableview to some specific number e.g. "500dp" or "90%".

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dcassenti Davide Cassenti
                Reviewer:
                Hieu Pham
                Tester:
                Lokesh Choudhary
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-17743
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration