Week 3 - Input Handling
Jim LaVine
jim.lavine @gmail.com
Agenda
• Mouse
• Touch
• Keyboard
• Event Bubbling
• Controls
• Introduction to Expression Blend
Code Behind<UserControl x:class="MyApp.Page">
xmlns:="http://schemas.microsoft.com/client/2007/"
xmlns:x="http://schemas.m...
Input Types
• Mouse
• Keyboard
• Touch
– Raw input only (no gestures) on non-mobile applications
– Windows phone has some ...
Mouse Input Events
Movement
MouseMove
MouseEnter
MouseLeave
LostMouseCapture
Mouse Button
MouseLeftButtonDown
MouseLeftBut...
Event Bubbling
• Events Bubble up the XAML Tree
– They do not bubble into the HTML tree
• Origin indicated by OriginalSour...
Mouse Capture
• Mouse can move out of element
– What if we still want events
• Capture mouse events
• Should release captu...
Right Mouse Button
• New in Silverlight 4
• No built-in custom context menu
– April 2010 Silverlight toolkit provides one:...
Mouse Wheel
• Platform=specific oddities
– NPAPI Limitations
– No Mac Support
• HTML DOM may work
– No OOB
Touch
• Touch input as mouse substitute
• Touch aware code
– Can handle multi-touch
– Specialized touch-based interaction
...
Keyboard
• KeyUp and KeyDown events
– KeyEventArgs.Key
– KeyEventArgs.PlatformKeyCode
• Focus
– Plug-in model makes this s...
Controls
• Textual input with TextBox
– Globalized
– Accessible
– Data bindable
• Button
– Accessible
Introduction to
Expression Blend
• The development environment
• Resources & Styles
• Customize controls
• Applying animat...
Reference Links
• http://channel9.msdn.com/shows/SilverlightTV/
• http://www.silverlight.net/learn/videos/expression/
• ht...
Target Applications
• WPF & Silverlight
• Sketchflow
Summary
• Mouse
• Touch
• Keyboard
• Event Bubbling
• Controls
• Expression Blend
Upcoming SlideShare
Loading in …5
×

Silverlight Input Handling

1,527 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,527
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • There are several ways for a user to interact with your application. The most obvious way is with the mouse. Silverlight offers event to track mouse and button movement as well as wheel activity.
    There is also the keyboard of course.
    Silverlight also supports touch screen events
  • Mouse events happen when the mouse is over the object and not its bounding box.
    You only get mouse events in the area that has been painted with a brush.
    Use the IsHitTestVisible property to ignore events.
  • Silverlight Input Handling

    1. 1. Week 3 - Input Handling Jim LaVine jim.lavine @gmail.com
    2. 2. Agenda • Mouse • Touch • Keyboard • Event Bubbling • Controls • Introduction to Expression Blend
    3. 3. Code Behind<UserControl x:class="MyApp.Page"> xmlns:="http://schemas.microsoft.com/client/2007/" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <Grid x:Name="LayoutRoot" Background="White"> <TextBlock x:Name="messageTextBlock"/> </Grid> </UserControl> Public partial class Page : UserControl { public Page() { InitializeComponent(); this.MouseLeftButtonDown += PageClick; } void PageClick(object sender, MouseButtonEventArgs e) { Point mousePos = e.GetPosition.this; messageTextBlock.Text = “Click at: “ + mousePos; } }
    4. 4. Input Types • Mouse • Keyboard • Touch – Raw input only (no gestures) on non-mobile applications – Windows phone has some gesture support
    5. 5. Mouse Input Events Movement MouseMove MouseEnter MouseLeave LostMouseCapture Mouse Button MouseLeftButtonDown MouseLeftButtonUp MouseRightButtonDown MouseRightButtonUp Wheel MouseWheel MouseEventArgs MouseWheelEventArgs MouseButtonEventArgs
    6. 6. Event Bubbling • Events Bubble up the XAML Tree – They do not bubble into the HTML tree • Origin indicated by OriginalSource • Set Handled=true to halt bubbling • No tunneling – No Preview events • Intrinsic events only
    7. 7. Mouse Capture • Mouse can move out of element – What if we still want events • Capture mouse events • Should release capture when done – May get early LostMouseCapture
    8. 8. Right Mouse Button • New in Silverlight 4 • No built-in custom context menu – April 2010 Silverlight toolkit provides one: http://silverlight.codeplex.com/ Silverlight
    9. 9. Mouse Wheel • Platform=specific oddities – NPAPI Limitations – No Mac Support • HTML DOM may work – No OOB
    10. 10. Touch • Touch input as mouse substitute • Touch aware code – Can handle multi-touch – Specialized touch-based interaction • Touch.FrameReported event – GetTouchPoints – GetPrimaryTouchPoint – SuspendMousePromotionUntilTouchUp • Gestures on Windows Phone 7 only
    11. 11. Keyboard • KeyUp and KeyDown events – KeyEventArgs.Key – KeyEventArgs.PlatformKeyCode • Focus – Plug-in model makes this slightly messy – Only Control-derived classes can receive focus
    12. 12. Controls • Textual input with TextBox – Globalized – Accessible – Data bindable • Button – Accessible
    13. 13. Introduction to Expression Blend • The development environment • Resources & Styles • Customize controls • Applying animation
    14. 14. Reference Links • http://channel9.msdn.com/shows/SilverlightTV/ • http://www.silverlight.net/learn/videos/expression/ • http://www.microsoft.com/design/toolbox/ • http://expression.microsoft.com/en- us/cc136522.aspx
    15. 15. Target Applications • WPF & Silverlight • Sketchflow
    16. 16. Summary • Mouse • Touch • Keyboard • Event Bubbling • Controls • Expression Blend

    ×