WPF: Difference between Mouse operation and Touch operation

N

Noriko Nakai

Hello.
I have created an program for the touch panel now.
It is a program, such as the following.

・MouseDown event of rectangle1 in the MainWindow, display the Window1 by ShowDialog Method.
・MouseDown event of rectangle2 in the Window1, close the Window1.

This program
In case of click on the rectangle1 by the mouse, Window1 closed by click onrectangle2.
But In case of touch of the rectangle1, Window1 can not closed by touch of rectangle2.
Window1 closed by touching of rectangle twice.


I have found that Window1 will be closed by touch of rectangle2.
Either of the following methods.
・When displaying the Window1, close the MainWindow.
・Instead of MouseDown, processed by MouseUp event.
・Instead of ShowDialog Method, display Window1 by Show Method.

Also, I checked difference of message by used Spy of Visual Studio Tool.
But, I do not know the cause.

Please let me ask a question.
Why there is a difference between mouse operation and touch operation?
Those differences will be based on specification, or will be based on this program?
Please let me know the cause of this problem.

Thanks.


â–  Environment

Windows 7 SP1 32bit
..NET Framework 3.5
Visual Studio 2010


â–  Sample

[MainWindow.xaml]

<Window x:Class="Sample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="184,67,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<Rectangle Height="100" HorizontalAlignment="Left" Margin="131,146,0,0" Name="rectangle1" Stroke="Black" VerticalAlignment="Top" Width="200" Fill="Red" MouseDown="rectangle1_MouseDown"/>
</Grid>
</Window>


[MainWindow.cs]

private void button1_Click(object sender, RoutedEventArgs e)
{
Window1 window = new Window1();
window.ShowDialog();
}

private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e)
{
Window1 window = new Window1();
window.ShowDialog();
}


[Window1.xaml]

<Window x:Class="Sample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Rectangle Height="100" HorizontalAlignment="Left" Margin="48,128,0,0" Name="rectangle1" Stroke="Black" VerticalAlignment="Top" Width="200" Fill="Blue" MouseDown="rectangle1_MouseDown"/>
</Grid>
</Window>


[Window1.cs]

private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e)
{
this.Close();
}
 
P

Phil Hunt

Touch screen can behave slightly differently than mouse. A touch can be
transformed to a double click. There is some setting on the touchscreen
driver you can set. Also look at the 'area' of the touch landing, it can
also make a difference.


Hello.
I have created an program for the touch panel now.
It is a program, such as the following.

?MouseDown event of rectangle1 in the MainWindow, display the Window1 by
ShowDialog Method.
?MouseDown event of rectangle2 in the Window1, close the Window1.

This program
In case of click on the rectangle1 by the mouse, Window1 closed by click on
rectangle2.
But In case of touch of the rectangle1, Window1 can not closed by touch of
rectangle2.
Window1 closed by touching of rectangle twice.


I have found that Window1 will be closed by touch of rectangle2.
Either of the following methods.
?When displaying the Window1, close the MainWindow.
?Instead of MouseDown, processed by MouseUp event.
?Instead of ShowDialog Method, display Window1 by Show Method.

Also, I checked difference of message by used Spy of Visual Studio Tool.
But, I do not know the cause.

Please let me ask a question.
Why there is a difference between mouse operation and touch operation?
Those differences will be based on specification, or will be based on this
program?
Please let me know the cause of this problem.

Thanks.


¡ö Environment

Windows 7 SP1 32bit
..NET Framework 3.5
Visual Studio 2010


¡ö Sample

[MainWindow.xaml]

<Window x:Class="Sample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left"
Margin="184,67,0,0" Name="button1" VerticalAlignment="Top" Width="75"
Click="button1_Click" />
<Rectangle Height="100" HorizontalAlignment="Left"
Margin="131,146,0,0" Name="rectangle1" Stroke="Black"
VerticalAlignment="Top" Width="200" Fill="Red"
MouseDown="rectangle1_MouseDown"/>
</Grid>
</Window>


[MainWindow.cs]

private void button1_Click(object sender, RoutedEventArgs e)
{
Window1 window = new Window1();
window.ShowDialog();
}

private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e)
{
Window1 window = new Window1();
window.ShowDialog();
}


[Window1.xaml]

<Window x:Class="Sample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Rectangle Height="100" HorizontalAlignment="Left"
Margin="48,128,0,0" Name="rectangle1" Stroke="Black" VerticalAlignment="Top"
Width="200" Fill="Blue" MouseDown="rectangle1_MouseDown"/>
</Grid>
</Window>


[Window1.cs]

private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e)
{
this.Close();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top