2013-09-05 2 views
0

У меня есть страница, как показано ниже:Невозможно сфокусироваться (нажмите) на элементы управления в контейнере ежевика каскады

import bb.cascades 1.0 

NavigationPane { ID: Nav страницу { // Корневой контейнер Контейнер { макет: DockLayout {}

 // Background 
     ImageView { 
      imageSource: "asset:///bg.png" 
      verticalAlignment: VerticalAlignment.Fill 
      horizontalAlignment: HorizontalAlignment.Fill 
     } 

     // Container for contents 
     Container { 
      layout: StackLayout { 
       orientation: LayoutOrientation.TopToBottom 
      } 

      // Top navigation : Login and Register buttons 
      Container { 
       layout: StackLayout { 
        orientation: LayoutOrientation.LeftToRight 
       } 

       ImageView { 
        id: tabLogin 
        imageSource: "asset:///ic_login_selected_tab.png" 
        onTouch: { 
         // Show login & hide register 
         loginContainer.setVisible(true) 
         registerContainer.setVisible(false) 

         // Change backgrounds 
         tabLogin.setImageSource(qsTr("asset:///ic_login_selected_tab.png")) 
         tabRegister.setImageSource(qsTr("asset:///ic_register_normal_tab.png")) 
        } 

       } 

       ImageView { 
        id: tabRegister 
        imageSource: "asset:///ic_register_normal_tab.png" 

        onTouch: { 
         loginContainer.setVisible(false) 
         registerContainer.setVisible(true) 
         tabLogin.setImageSource(qsTr("asset:///ic_login_normal_tab.png")) 
         tabRegister.setImageSource(qsTr("asset:///ic_register_selected_tab.png")) 
        } 
       } 

      } 

      // Container for Login and Register pages 
      Container { 
       horizontalAlignment: HorizontalAlignment.Fill 
       layout: DockLayout { 
       } 

       // Login container 
       Container { 
        id: loginContainer 
        visible: true 
        horizontalAlignment: HorizontalAlignment.Fill 
        layout: StackLayout { 
         orientation: LayoutOrientation.TopToBottom 
        } 

        topPadding: 200 

        // safeMATE text 
        ImageView { 
         verticalAlignment: VerticalAlignment.Top 
         horizontalAlignment: HorizontalAlignment.Center 
         imageSource: "asset:///safemate.png" 
        } 

        // Container for email, passcode and login button 
        Container { 
         horizontalAlignment: HorizontalAlignment.Fill 
         verticalAlignment: VerticalAlignment.Center 

         topMargin: 100 
         bottomMargin: 50.0 
         Container { 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          background: Color.White 
          horizontalAlignment: HorizontalAlignment.Fill 

          leftPadding: 20.0 
          rightPadding: 30.0 
          topPadding: 25 
          bottomPadding: 25 
          bottomMargin: 5.0 
          topMargin: 5.0 
          leftMargin: 5.0 
          rightMargin: 5.0 
          layoutProperties: StackLayoutProperties { 

          } 

          ImageView { 
           imageSource: "asset:///ic_email.png" 
          } 
          TextField { 
           hintText: "Email" 
           inputMode: TextFieldInputMode.EmailAddress 
          } 

         } 

         Container { 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          background: Color.White 
          horizontalAlignment: HorizontalAlignment.Fill 

          leftPadding: 20.0 
          rightPadding: 30.0 
          topPadding: 25 
          bottomPadding: 25 

          bottomMargin: 5.0 
          topMargin: 5.0 
          leftMargin: 5.0 
          rightMargin: 5.0 
          layoutProperties: StackLayoutProperties { 

          } 
          ImageView { 
           imageSource: "asset:///ic_passcode.png" 
          } 

          TextField { 
           hintText: "Passcode" 
           inputMode: TextFieldInputMode.Password 
          } 

         } 

         ImageButton { 
          horizontalAlignment: HorizontalAlignment.Fill 
          defaultImageSource: "asset:///btn_login.png" 
          pressedImageSource: "asset:///btn_login_clicked.png" 

          onClicked: { 
           var page = homePage.createObject(); 

           nav.push(page); 
          } 
         } 
        } 
       } 

       // Register container 
       ScrollView { 

        Container { 
         id: registerContainer 
         visible: false 
        horizontalAlignment: HorizontalAlignment.Fill 
        layout: StackLayout { 
         orientation: LayoutOrientation.TopToBottom 
        } 

        topPadding: 30 

        // safeMATE text 
        ImageView { 
         verticalAlignment: VerticalAlignment.Top 
         horizontalAlignment: HorizontalAlignment.Center 
         imageSource: "asset:///safemate.png" 
        } 

        // Container for email, passcode and login button 
        Container { 
         horizontalAlignment: HorizontalAlignment.Fill 
         verticalAlignment: VerticalAlignment.Center 

         topMargin: 30 
         bottomMargin: 50.0 

         // Email 
         Container { 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          background: Color.White 
          horizontalAlignment: HorizontalAlignment.Fill 

          leftPadding: 20.0 
          rightPadding: 30.0 
          topPadding: 25 
          bottomPadding: 25 
          bottomMargin: 5.0 
          topMargin: 5.0 
          leftMargin: 5.0 
          rightMargin: 5.0 
          layoutProperties: StackLayoutProperties { 

          } 

          ImageView { 
           imageSource: "asset:///ic_email.png" 
          } 
          TextField { 
           hintText: "Email" 
           inputMode: TextFieldInputMode.EmailAddress 
          } 

         } 

         // Full name 
         Container { 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          background: Color.White 
          horizontalAlignment: HorizontalAlignment.Fill 

          leftPadding: 20.0 
          rightPadding: 30.0 
          topPadding: 25 
          bottomPadding: 25 
          bottomMargin: 5.0 
          topMargin: 5.0 
          leftMargin: 5.0 
          rightMargin: 5.0 
          layoutProperties: StackLayoutProperties { 

          } 

          ImageView { 
           imageSource: "asset:///ic_fullname.png" 
          } 
          TextField { 
           hintText: "Full name" 
           inputMode: TextFieldInputMode.Default 
          } 

         } 

         // Passcode 
         Container { 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          background: Color.White 
          horizontalAlignment: HorizontalAlignment.Fill 

          leftPadding: 20.0 
          rightPadding: 30.0 
          topPadding: 25 
          bottomPadding: 25 

          bottomMargin: 5.0 
          topMargin: 5.0 
          leftMargin: 5.0 
          rightMargin: 5.0 
          layoutProperties: StackLayoutProperties { 

          } 
          ImageView { 
           imageSource: "asset:///ic_passcode.png" 
          } 

          TextField { 
           hintText: "Passcode" 
           inputMode: TextFieldInputMode.Password 
          } 

         } 

         // Phone 
         Container { 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          // Country code 
          Container { 
           layout: StackLayout { 
            orientation: LayoutOrientation.LeftToRight 
           } 

           background: Color.White 

           leftPadding: 20.0 
           rightPadding: 30.0 
           topPadding: 35 
           bottomPadding: 35 
           bottomMargin: 5.0 
           topMargin: 5.0 
           leftMargin: 5.0 
           rightMargin: 5.0 
           layoutProperties: StackLayoutProperties { 

           } 

           ImageView { 
            imageSource: "asset:///ic_phonenumber.png" 
           } 


          } 

          // Phone 
          Container { 
           horizontalAlignment: HorizontalAlignment.Fill 
           layout: StackLayout { 
            orientation: LayoutOrientation.LeftToRight 
           } 

           background: Color.White 

           leftPadding: 20.0 
           rightPadding: 30.0 
           topPadding: 23 
           bottomPadding: 23 
           bottomMargin: 5.0 
           topMargin: 5.0 
           leftMargin: 5.0 
           rightMargin: 5.0 
           layoutProperties: StackLayoutProperties { 

           } 

           // Phone number text box 
           TextField { 
            hintText: "Phone number" 
            inputMode: TextFieldInputMode.Default 
           } 
          } 
         } 

         // Contact info title 
         Container { 
          topMargin: 20 
          horizontalAlignment: HorizontalAlignment.Fill 
          layout: StackLayout { 
           orientation: LayoutOrientation.LeftToRight 
          } 

          ImageView { 
           imageSource: "asset:///ic_contactinfo.png" 
          } 

          Container { 
           leftPadding: 20 
           layout: StackLayout { 
            orientation: LayoutOrientation.TopToBottom 
           } 

           Label { 
            verticalAlignment: VerticalAlignment.Center 
            text: "CONTACT INFO" 
           } 
           Label { 
            text: "These information will be used for emergencies" 
            multiline: true 
            textStyle.fontSize: FontSize.XSmall 
           } 
          } 

         } 

         // Contact info container 
         Container { 
          topMargin: 20 
          horizontalAlignment: HorizontalAlignment.Fill 
          verticalAlignment: VerticalAlignment.Center 
          layout: StackLayout { 
           orientation: LayoutOrientation.TopToBottom 
          } 

          // Phone 
          Container { 

           layout: StackLayout { 
            orientation: LayoutOrientation.LeftToRight 
           } 

           // Country code 
           Container { 
            layout: StackLayout { 
             orientation: LayoutOrientation.LeftToRight 
            } 

            background: Color.White 

            leftPadding: 20.0 
            rightPadding: 30.0 
            topPadding: 35 
            bottomPadding: 35 
            bottomMargin: 5.0 
            topMargin: 5.0 
            leftMargin: 5.0 
            rightMargin: 5.0 
            layoutProperties: StackLayoutProperties { 

            } 

            ImageView { 
             imageSource: "asset:///ic_phonenumber.png" 
            } 
           } 

           // Phone 
           Container { 
            horizontalAlignment: HorizontalAlignment.Fill 
            layout: StackLayout { 
             orientation: LayoutOrientation.LeftToRight 
            } 

            background: Color.White 

            leftPadding: 20.0 
            rightPadding: 30.0 
            topPadding: 23 
            bottomPadding: 23 
            bottomMargin: 5.0 
            topMargin: 5.0 
            leftMargin: 5.0 
            rightMargin: 5.0 
            layoutProperties: StackLayoutProperties { 

            } 

            // Phone number text box 
            TextField { 
             hintText: "Phone number" 
             inputMode: TextFieldInputMode.Default 
            } 
           } 
          } 

          // Address 
          Container { 
           layout: StackLayout { 
            orientation: LayoutOrientation.LeftToRight 
           } 

           background: Color.White 
           horizontalAlignment: HorizontalAlignment.Fill 

           leftPadding: 20.0 
           rightPadding: 30.0 
           topPadding: 25 
           bottomPadding: 25 
           bottomMargin: 5.0 
           topMargin: 5.0 
           leftMargin: 5.0 
           rightMargin: 5.0 
           layoutProperties: StackLayoutProperties { 

           } 

           ImageView { 
            imageSource: "asset:///ic_address.png" 
           } 
           TextField { 
            hintText: "Address" 
            inputMode: TextFieldInputMode.EmailAddress 
           } 

          } 
         } 

         // Register button 
         ImageButton { 
          horizontalAlignment: HorizontalAlignment.Fill 
          defaultImageSource: "asset:///btn_register.png" 
          pressedImageSource: "asset:///btn_register_clicked.png" 

          onClicked: { 
           var page = homePage.createObject(); 

           nav.push(page); 
          } 
         } 
        } 
       } 
     } 
      } 
     } 
    } 
} 

attachedObjects: [ 
    ComponentDefinition { 
     id: homePage 
     source: "home.qml" 
    } 
] 

onPopTransitionEnded: { 
    // Transition is done destroy the Page to free up memory. 
    page.destroy(); 
} 

}

У меня есть 2 кнопки вверху страницы, чтобы перемещаться между Login и Register. Проблема в том, что я не могу сфокусироваться (входные тексты или нажать кнопку) в контейнере Login (но контейнер регистрации работает хорошо).

Пожалуйста, дайте мне знать, как решить эту проблему

ответ

2

Если я положил его в IDE я сразу же получить

свойства по умолчанию для компонента «Страницы» не принимает несколько объектов.

Итак, поставьте Контейнер вокруг двух ваших контейнеров, так что Страница будет иметь только один элемент внутри.

import bb.cascades 1.0 
Page { 
    Container { 

     // Login container 
     Container { 
      // Email 
      TextField { 
      } 
      // Password 
      TextField { 
      } 
      // Button login 
      Button { 
      } 
     } 
     // Register container 
     Container { 
      // Email 
      TextField { 
      } 
      // Password 
      TextField { 
      } 
      // Button register 
      Button { 
      } 
     } 
    } 
} 

EDIT:

Поскольку вы добавили полный код, есть еще одна проблема. Вы создали свой Контейнер входа, а затем создаете «ScrollView», который предназначен для регистрации нового пользователя. Проблема ScrollView была создана сверху Логин Контейнер, и хотя он не виден, он блокирует контейнер ниже. Два решения:

  • Создайте отдельную страницу для регистрации нового пользователя
  • Переместить свой логин контейнер под ScrollView. Немного удачи, которые должны выполнять работу (и не отключать регистрацию). Поскольку вы используете DockLayout, который не должен разрушать ваш дизайн
+0

Спасибо! Я обновил свой вопрос. Проблема в том, что я не могу сосредоточиться на контейнере Login –

+0

Вы хотите сосредоточиться на электронной почте при ее открытии? –

+0

При открытии приложения открывается страница входа в систему, но я не могу сосредоточиться на электронной почте, пароле или кнопке входа. Когда я перехожу на страницу «Регистрация», я могу сосредоточиться на любом элементе управления (я могу ввести адрес электронной почты, пароль и нажать кнопку «Регистрация»). –

Смежные вопросы