Is there a way I can change the default system mouse pointer from within my application and change it back to the original scheme when I want to?
You can use the Cursor class to create a custom cursor, and you can set the mouse pointer to use that cursor while it's over your application.
Related
I have a Windows 8 application, and I need to detect when the mouse is at the bottom of the screen because my application has a CommandBar, and I would like to open it when the mouse is at the bottom. I already have swipe gestures that will open it when the user swipes, but now I have an added requirement for when the user does not have a touch device and instead must bring the mouse to the bottom of the screen to show my CommandBar. I am used to WPF's style of MouseMoved events, but unfortunately these are not available in Metro applications, so how can I get the mouse position or at least detect that the user has brought the mouse to the bottom of the screen? I have tried searching about this, but I couldn't find anything...perhaps I am missing something?
As Chue X said the standard way to open the app bar by mouse is right click.
Windows Runtime apps use Pointer messages for all pointer input: Mouse, touch and pen will all generate PointerPressed, PointerMoved, etc. You can examine the Pointer event args to see which type of input it is in the PointerPoint.PointerDevice.PointerDeviceType.
There are slightly different versions of the Pointer events on the CoreWindow (with full window scope) and on the xaml UIElement (scoped to the element). You can use either in a xaml app. For your use either would work. They give essentially the same information.
Responding to mouse interactions (XAML) http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994936.aspx
Here's the code I used to achieve this behavior from any OnPointerMoved event handler:
... OnPointerMoved(PointerRoutedEventArgs e)
{
PointerPoint point = e.GetCurrentPoint(page);
if (point.Position.Y > page.RenderSize.Height - 5)
{
page.MainMenu.IsOpen = true;
}
}
I am working on a silverlight application that has to capture electronic signature from user as a part of it's functionality. I was able to build a PoC based on Silverlight Ink Presenter control, when the page renders I have designated a rectangular region into which user has to input his signature.
This absolutely works like a charm, but, I wsa not able to restrict pointing device to rectangular region so it can currently go out of the region irritating the user. User has to get it back to the rectangular region to input his signature. I would like to know if there is a way to restrict cursor to a rectangular region of the web page.
Something similar to "Cursor.Clip" of Windows.Forms
Any help is highly appreciated.
Try designing your own cursor as the pointer enters the region and hide the pointer. Set the bounds of the custom cursor to stay with int rectangle
here's a link for custom cursor
custom cursor
Only problem is as you move it along with the mouse pointer then mouse pointer can move out but this cursor wont. Rest of the code you need to modify so that user sticks to the particular edges
In my application, there are two instances where I would like to use a non-default cursor.
One is on a panel which the user may "draw" on using the mouse. I would like to change the cursor from the default mouse to a pen or paintbrush. I would like to get an image from online, convert it to the appropriate filetype and use it as my cursor for the panel.
The other instance is when an image is added to a rich text box. I would like to add the correct "resize" arrows so that when the user hovers the mouse over one of the small black boxes, the cursor changes to the double arrow (like in other programs).
How easy is this to achieve?
I don't have a clue where to start when it comes to implementing the resize arrows, as there isn't always an image in the rich text box (only when the application is being debugged or used).
There is actually a cursor option for winforms in the properties tab, you could change the cursor whenever the Cursor.Position is equal to the item's position.
Even better, use the MouseHover event and add a new handler to change the cursor when it is called.
All of the controls in WinForms have a Cursor property, since they all inherit from System.Windows.Forms.Control. Whatever cursor you assign to this property will be displayed automatically when the mouse pointer is over that control.
This is an ambient property, which means that it automatically inherits its value from its parent (for example, a Button control would automatically use the same cursor as its parent form) unless it is explicitly set otherwise.
So to change the cursor displayed over a certain control, all you need to do is set that control object's Cursor property. The framework will take care of the rest.
I want to make a small box that will be visible after PointerEntered event on bing map. I need to get the position of pointer when the pointer is over the pushpin. Everything works but I can't get the position. I need it so I can dynamicly show the box in correct place near the pushpin.
How can I get cursor/pointer position ?
I don't think it's a good idea trying to rely too much on pointer position in Windows Store apps. Don't forget about your touch based users - how are you going to determine the pointer position in their case?
I haven't used Bing maps and pushpins in a Windows Store app yet, but maybe you could try using tooltips instead. They already have built-in support for both touch based and mouse based control and they even position themselves automatically in such a way that the user doesn't obsure them with his finger.
I'm making a Windows Store app in C# and I have a normal TextBlock with a link inside it. And all I want to do it to make the cursor change into a hand when it goes over the text block, but unlike in WPF applications, there is no Cursor propriety. I know is a CoreCursor class in Windows.UI.Core. Am I suppose to use it somehow?
Window.Current.CoreWindow.PointerCursor =
new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);
WinRT XAML Toolkit has an attached property that works just about the same as the Cursor property in WPF in that you set a cursor for an element and so when your mouse cursor hovers on top of that element - the cursor changes to what the property specifies and when it leaves control bounds - it restores the previous cursor. There are actually two properties - one called FrameworkElementExtensions.SystemCursor that takes any standard cursor from the CoreCursorType enum, which you just use like in this sample page - set
<Border
xmlns:Extensions="using:WinRTXamlToolkit.Controls.Extensions"
Extensions:FrameworkElementExtensions.SystemCursor="Cross"/>
The other one - FrameworkElementExtensions.Cursor allows you to set any custom cursor, but I believe you'd need to set it in code behind like FrameworkElementExtensions.SetCursor(myElement, myCursor); or bind to a cursor property set elsewhere.
You can also use custom cursors. You need to define a cursor in a native resource library as described in this article and then you should be able to set them either globally by setting the Window.Current.CoreWindow.PointerCursor property or with an attached property like my FrameworkElementExtensions.Cursor.