locked
[UWP][C++]UWP C++ Aplication not taking or registering any mouse input RRS feed

  • Question

  • I have created a UWP C++  Application and populated it with these controls:

    <StackPanel Orientation="Horizontal">
        <TextBox Name="textToAddTo"/>
        <Button Name="addTextToLabelButton" Content="Add Text" Click="addTextToLabelButton_Click"/>
    </StackPanel>
     <TextBlock Name="ExistText"/>

    With this code behind:

    void CrystalLibUWPC::MainPage::addTextToLabelButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { ExistText->Text += textToAddTo->Text; }

    My problem is that the application will not take ANY mouse input, but it will take keyboard input, so I can press the tab  key to select and press enter on controls, as this video shows : https://1drv.ms/v/s!AgBD_3oNIAengqNrYkwikgcI2-Be6A

    Any help wold be appreciated,

    Josh




    Sunday, March 5, 2017 6:43 PM

Answers

  • Hello Josh,

    You are putting your textblock and textbox together and then the UI mixed together.

    Please understand the following:

    1. Textbox is a control for input so it can receive inputs from both mouse and keyboard

    2. Textblock can be treated as a label and in this way it will not receive inputs.

    So please modify you UI code like the following:

     <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Grid.RowDefinitions>
                <RowDefinition Height="400"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border BorderBrush="Black" Grid.Row="0">
                <StackPanel>
                    <TextBox Name="textToAddTo"/>
                    <Button Name="addTextToLabelButton" Content="Add Text" Click="addTextToLabelButton_Click"/>
                </StackPanel>
            </Border>
            <Border BorderBrush="Black" Grid.Row="1">
                <StackPanel>
                    <TextBlock Name="ExistText"/>
                </StackPanel>
            </Border>
        </Grid>

    In this way the UI looks different and you will be able to see the difference.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 6, 2017 9:45 AM