Skip to content

Commit

Permalink
highlight url text input contents by default
Browse files Browse the repository at this point in the history
  • Loading branch information
stakes committed Dec 12, 2014
1 parent 2349f85 commit 18c48a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Frameless/FramelessSearchBar.swift
Expand Up @@ -12,6 +12,7 @@ class FramelessSearchBar: UISearchBar {

var framelessSearchBarDelegate:FramelessSearchBarDelegate?
var _refreshButton:UIButton!
var _field:UITextField!

func handleRefreshTap() {
framelessSearchBarDelegate?.searchBarRefreshWasPressed!()
Expand Down Expand Up @@ -58,6 +59,7 @@ class FramelessSearchBar: UISearchBar {
}
}
if let field = searchField {
_field = field
var iconImage = UIImage(named: "refresh")
var iconImageDisabled = UIImage(named: "refresh-disabled")
if _refreshButton == nil {
Expand All @@ -71,6 +73,14 @@ class FramelessSearchBar: UISearchBar {
}
}
}

func selectAllText() {
if let field = _field {
if field.text != "" {
field.selectAll(self)
}
}
}

}

Expand Down
1 change: 1 addition & 0 deletions Frameless/ViewController.swift
Expand Up @@ -122,6 +122,7 @@ class ViewController: UIViewController, UISearchBarDelegate, FramelessSearchBarD
let dict:NSDictionary = sender.userInfo! as NSDictionary
let s:NSValue = dict.valueForKey(UIKeyboardFrameEndUserInfoKey) as NSValue
let rect :CGRect = s.CGRectValue()
_searchBar.selectAllText()
_settingsBarView!.frame.origin.y = self.view.frame.height - rect.height - _settingsBarView!.frame.height
_settingsBarView!.alpha = 1
}
Expand Down

0 comments on commit 18c48a0

Please sign in to comment.