demos/declarative/webbrowser/content/UrlInput.qml
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    46 
    46 
    47     property alias image: bg.source
    47     property alias image: bg.source
    48     property alias url: urlText.text
    48     property alias url: urlText.text
    49 
    49 
    50     signal urlEntered(string url)
    50     signal urlEntered(string url)
       
    51     signal urlChanged
    51 
    52 
    52     width: parent.height; height: parent.height
    53     width: parent.height; height: parent.height
    53 
    54 
    54     BorderImage {
    55     BorderImage {
    55         id: bg; rotation: 180
    56         id: bg; rotation: 180
    66     }
    67     }
    67 
    68 
    68     TextInput {
    69     TextInput {
    69         id: urlText
    70         id: urlText
    70         horizontalAlignment: TextEdit.AlignLeft
    71         horizontalAlignment: TextEdit.AlignLeft
    71         font.pixelSize: 14; focusOnPress: true
    72         font.pixelSize: 14;
       
    73 
       
    74         onTextChanged: container.urlChanged()
       
    75 
    72         Keys.onEscapePressed: {
    76         Keys.onEscapePressed: {
    73             urlText.text = webView.url
    77             urlText.text = webView.url
    74             webView.focus = true
    78             webView.focus = true
    75         }
    79         }
       
    80 
       
    81         Keys.onEnterPressed: {
       
    82             container.urlEntered(urlText.text)
       
    83             webView.focus = true
       
    84         }
       
    85 
    76         Keys.onReturnPressed: {
    86         Keys.onReturnPressed: {
    77             container.urlEntered(urlText.text)
    87             container.urlEntered(urlText.text)
    78             webView.focus = true
    88             webView.focus = true
    79         }
    89         }
       
    90 
    80         anchors {
    91         anchors {
    81             left: parent.left; right: parent.right; leftMargin: 18; rightMargin: 18
    92             left: parent.left; right: parent.right; leftMargin: 18; rightMargin: 18
    82             verticalCenter: parent.verticalCenter
    93             verticalCenter: parent.verticalCenter
    83         }
    94         }
    84     }
    95     }