New Features of Silverlight 5 beta: 4. Implementation of double-click and multi-click in Silverlight 5 beta

Source: Internet
Author: User

The implementation of double-click and multiple-click is added in Silverlight 5, including the left-click and right-click double-click, multiple-click. In the mousebuttoneventargs class of Silverlight 5, a property named clickcount is added: the trigger event source is obtained inUnit timeNumber of inner clicks (note:Unit timeIs set by the "control panel" --> "Mouse" --> "double-click speed" of the operating system ).

Next, let's look at an instance to determine whether to double-click or multi-click it. First, let's look at the instance's XAMLCode:

   <  Grid X: Name  =  "  Layoutroot  "  Background  = "  White  "  >  
< Ellipse height = " 103 " Horizontalalignment = " Left " Fill = " Green " Margin = " 117,56, 0, 0 "
Name = " Ellipse1 " Stroke = " Black " Strokethickness = " 1 " Verticalalignment = " Top "
Width = " 158 " Mouseleftbuttondown = " Ellipse1_mouseleftbuttondown "
Mouserightbuttondown = " Ellipse2_mouserightbuttondown " />
</ Grid >

1. Let's take a look at double-clicking the left mouse button (similar to triple-clicking). The judgment is as follows:

  Private     Void  Ellipse1_mouseleftbuttondown (  Object  Sender, mousebuttoneventargs E)
{
// Determines that the mouse is clicked twice within the double-click interval set by the system. The window is displayed.
If (E. clickcount = 2 )
{
MessageBox. Show ( " Left mouse click " + E. clickcount. tostring ());
}
}

When you double-click the left mouse button, the result is as follows:

2. In some cases, we need to determine whether to double-click or triple-click the right mouse. In this case, just enter the following code:

   Private     Void  Ellipse2_mouserightbuttondown (  Object Sender, mousebuttoneventargs E)
{
// Right-click and choose 3.
If (E. clickcount = 3 )
{
MessageBox. Show ( " Right-click " + E. clickcount. tostring () + " Times! " );
}
}

However, when we run it, we find that the slice effect is shown, but it cannot be right-clicked:

By default, Microsoft has a right-click menu. You need to disable this default right-click menu to enable multiple clicks.

A. On the sl5doubleclicktestpage. ASPX page, change the <body> element to <body oncontextmenu = "window. event. returnvalue = false">.

B. Add a line in the <Object> label <Param name = "windowless" value = "true"/> to disable the default right-click menu.

The effect of right-click and three-click operations is as follows:

This example is written in vs2010 + Silverlight 5 beta. To download the source code, click sl5doubleclick.zip.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.