Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
tapText() for Android, added to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Frank committed May 20, 2012
1 parent babc4b3 commit d52ed1b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ Check if a view is visible on screen.

Attempt to type the specified string into the specified view.

### tapText (string)

Search for a view displaying the given string and tap it if found. The string
argument will be interpereted internally as a regex.

## Usage

You can extract the module zip files into your project directory and edit
Expand Down
Binary file modified android/dist/org.russfrank.spade-android-0.1.zip
Binary file not shown.
38 changes: 9 additions & 29 deletions android/example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,23 @@ var spade = require('org.russfrank.spade');

var win = Ti.UI.createWindow({
backgroundColor:'white',
layout: 'vertical',
navBarHidden: true
layout: 'vertical'
});

var view1 = Ti.UI.createView({ backgroundColor:'#123', width: 250 });
var view2 = Ti.UI.createView({ backgroundColor:'#246', width: 250 });
var view3 = Ti.UI.createView({ backgroundColor:'#48b', width: 250 });

var scrollableView = Ti.UI.createScrollableView({
views: [view1,view2,view3],
showPagingControl: true,
width: 320,
height: 300
var btn = Ti.UI.createButton({
title: 'this is a test'
});

var field = Ti.UI.createTextField({width: 200, height: 40, borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED});

win.add(field);
win.add(scrollableView);
win.add(btn);

scrollableView.addEventListener('scroll', function () {
Ti.API.debug('view1 says ' + spade.visible(view1));
Ti.API.debug('view2 says ' + spade.visible(view2));
Ti.API.debug('view3 says ' + spade.visible(view3));
});
btn.addEventListener('click', function () { alert('clicked'); });

setTimeout(function () {
spade.drag(scrollableView, {x: 319, y: 200}, {x: 1, y: 200});
spade.tapAt(view1, {x: 10, y: 40});
//var searched = spade.find('this.*test');

//if (searched) spade.tap(searched);

spade.tapText('this.*test');
}, 3000);

view1.addEventListener('click', function (e) { Ti.API.debug(e); });

win.open();

setTimeout(function() {
spade.tap(field);
spade.type(field, "HELLO WORLD, hello world!");
}, 2000);
5 changes: 5 additions & 0 deletions android/src/org/russfrank/spade/SpadeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ public boolean type(ViewProxy proxy, String text) {
return true;
}

@Kroll.method
public void tapText(String text) {
mSolo.clickOnText(text);
}

private void dictToPoint(KrollDict point, int[] pointOut) throws IllegalArgumentException {
if (!point.containsKey("x")) {
throw new IllegalArgumentException("spade: required property \"x\" not found in point");
Expand Down

0 comments on commit d52ed1b

Please sign in to comment.