[TIMOB-3223] iOS - showBookmark missing from searchBar
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-04-18T10:56:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 2.1.0 |
Components | iOS |
Labels | core, qe-testadded |
Reporter | Pedro Enrique |
Assignee | Neeraj Gupta |
Created | 2011-04-15T03:39:50.000+0000 |
Updated | 2013-11-06T19:24:12.000+0000 |
Description
According to Apple's [Documentation](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UISearchBar_Class/Reference/Reference.html%23//apple_ref/doc/uid/TP40007529) there is a property for the searchbar that adds a Bookmark icon to the right side of it.
I modified a little bit the Obj-C code. Specifically, I added the following code to TiUISearchBar.m and now it is working as expected:
-(void)setShowBookmark_:(id)value
{
UISearchBar *search = [self searchBar];
[search setShowsBookmarkButton:[TiUtils boolValue:value]];
[search sizeToFit];
}
To make this work on Titanium's code just added it to the searchbar with showBookmark true:
var search = Ti.UI.createSearchBar({
hintText: "Type Something",
top:0,
height:44,
showBookmark: true
});
Then for it's listener, I modified the Obj-C code a little more:
// called when bookmark button pressed
- (void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar
{
//TODO: update to the new event model
NSString * text = [searchBar text];
[self.proxy replaceValue:text forKey:@"value" notification:NO];
if ([self.proxy _hasListeners:@"bookmark"])
{
[self.proxy fireEvent:@"bookmark" withObject:[NSDictionary dictionaryWithObject:text forKey:@"value"]];
}
if (delegate!=nil && [delegate respondsToSelector:@selector(searchBarBookmarkButtonClicked:)])
{
[delegate searchBarBookmarkButtonClicked:searchBar];
}
}
And the JS is like this:
search.addEventListener('bookmark', function(e){
alert(e);
});
Tested in Ti SDK 1.6 Release
iPhone Simulator 4.2
This feature is necessary for our project, if it can be prioritized.
As a low priority item, this will not be looked at until after Sprint 16.
I've pulled request on github for Pedro Enrique's solution with adding documentation. See here: https://github.com/appcelerator/titanium_mobile/pull/1458 Ticket is already tagged for 1.8.0 release but I hope it'll be included in next release.
Tested with: Titanium SDK: 2.0.0 (04/06/12 00:35 8e4d621) iPhone SDK: 5.0 iPhone Simulator Screenshots: [http://oi41.tinypic.com/34skkcy.jpg] [http://oi42.tinypic.com/xeg3ee.jpg] [http://oi41.tinypic.com/2ibnf9s.jpg] [http://oi42.tinypic.com/30nayxs.jpg] Here are the functional test application source code:
Here is an additional test which should be run:
Searchbar w/bookmark in tableview
Tested with 2.1.0.v20120606112649 iPad 3 5.1.1 and iPhone 3gs 4.3
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4758