I don't like the default ToolTip behavior. First, I don't like that, after tooltip is shown for "AutoPopDelay" miliseconds, it disappears and don't appear anymore if you move the mouse over the control again. Second, I don't like that AutoPopDelay is limited to 5000 miliseconds.
I found one way to make tooltip always reappear on mouse move over control, even if it was shown for a time exceeding AutoPopDelay value: I call toolTip.Hide() in MouseLeave handler. This way tooltip will appear again on mouse over.
But I haven't found a simple way to make tooltip stay shown for longer time (longer than maximum 5000 miliseconds). If I call toolTip.Show() in MouseEnter handler, then toolTip is shown in not good position. I like the position in which it shows automatically :)
So, what can you suggest?
Use the Show method to control the length of time (it is not limited to 5000ms).
There is a signature for Show that does not require that you set the relative coordinates and there is one that will take the coordinates if you want to fine-tune things. In your case you will need to pass coordinates (if you don't like what it automatically gives you). I do not believe there to be an alternative...
Related
My UWP application contains a map with several POI. I am trying to change the mouse cursor from an arrow to a hand when hovering over specific poi to indicate its clickable.
This would change the cursor as soon as it enters the map still, as a simple test, I added a PointerEntered event for the mapcontrol and within it I have the following to change the cursor:
Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 0);
It appears though the cursor does change however immediately gets overridden back to the pointer cursor.
Edit: Just realised When a poi is clicked (i.e. is selected) the cursor changes to a hand even when not over the map control until the poi is unselected. No good as I would like the cursor to change dynamically when hovering over a poi and revert back to cursor when moved away.
Change pointer cursor when hovering over map elements
I'm afraid you can't edit the default cursor for map element, Because it has handled internally, it will not fired, even you has listen PointerEntered event, it consumed by the control and not passed up the control chain. If you do want this feature, the better way is post this feature with windows feed backhub app.
I don't know if it works just like WinForms, I had to do something like this to click on labels (couldn't use link-labels), what I used was in the Mouse_Move event of the label and it was basically
if (Cursor.Current == Cursors.Default)
{
Cursor.Current = Cursors.Hand;
}
and similar changes and behaviors due to the various conditions. This however got me a small issue: this statement changes the mouse graphic anytime you move on the control, but personally on Windows settings I use the trail graphic function for the mouse (leaving a trail of pointers whenever I move the mouse on the screen), what I suggested you disables this function, or better, it conceals it, since it "recreates" the mouse graphic for every move you do onto the control, and thus it "undoes" the graphic for the mouse and recreates it as a Hand (in my instance). If it doesn't concern you though, it works just fine.
Just I repeat myself: I use this on WinForms, but since it's C# I suppose it just will work(?)
I just wasted my entire evening on something which I thought would be very simple but it seems WPF and Google are letting me down completely.
I need a grid, 6x6 of which I fill every row and column with a custom control. I want to be able to navigate through this grid via the keyboard (I can get those events, no problem) but I cannot seem to find how I can always have the selected grid row/column in the center of my window.
I found some carousel alike implementations, but most of them only work in a single direction and I want two way navigation, yet none seem to support this nor can I extend them to do this.
I essentially want to create a PSP alike grid navigation.
One easy way is to do this:
Create a scrollable form.
Add a 6x6 grid of child controls.
In the GotFocus (or similar) event for all the controls, set the parent form scroll offset to an appropriate position to centre the child.
This is pretty straight-forward thing to implement, with a little bit of maths to work out how to centre the x,y position of a control by setting the scroll offsets (it can be tricky/confusing, but as long as you understand the coordinate systems used for scrolling, not too bad)
Or, another approach that avoids scrolling via the windows APIs and using custom controls:
Create a form
Override OnPaint to draw your grid of 6x6 "controls" as simple graphical shapes or bitmap images centred on the selected "control".
Handle keyboard (KeyDown/Up) and mouse handling (MouseDown/Up) events to make the 36 areas of the graphic respond to user inputs in the way you desire. You'll have to track the selected item and force the window to redraw its graphics to show the new state. Enable double buffering to stop it flickering.
The first approach gives you a lot of windows-based handling for free (tabbing between controls, remembering where the input focus is, and directing events to separate classes for each "control", for example). The second approach strips away all this "help" but gives you complete control over everything, which can often help avoid unintended behaviours (e.g. it won't move the input focus when the user presses Tab unless you specifically write the code to make it do that).
If you have a focus on a textbox but mousecursor not exactly hovering on it, mousecursor has default arrow shape or whatever you define.
At the time when you start typing, mousecursor hide itself and you see only blinking stick IBeam type cursor in the textbox.
Question: How to hold mousecursor on its initial position even if you start typing?
Interestingly enough: this doesn't happen in WPF apps.
Guys... That was ridiculously easy. In TextBox.KeyDown I have to move the Cursor every time to point where it was before..
Cursor.Position = new Point( oldX, oldY );
The only ugly thing here - if it's an animated cursor, animation starts everytime all over again. And also you can't type and move the mouse at the same time. That
's kind'a suck, on the other hand who cares? Winform apps tend to be uglier than WPF ones, isn't that true?
I'm going to answer the question. The side-effects and repercussions are your responsibility. Is there another way of doing it? I'm certain.
Create a "state" variable to hold the state of whether a user is typing or not. Textboxes have various events to let you know when someone is typing, EN_CHANGE, etc., that whole family of events and so on. Set state variable true when user is typing. False when not typing, EN_LOSTFOCUS, etc.
Trap mouse input through a PreProcessMessage event or PreTranslateMessage event, or any that seem appropriate.
Call "ShowCursor" or potentially "SetCursor" in the OnPaint event whilst the state variable is true. Yep, hairy, eh. Do not call it while the state variable is false.
Debug, debug, debug after this. HTH
If this is not clear post and I'll expand my answer.
This is a Windows setting.
Under Control Panel, go to Mouse and then you should see a setting similar to "Hide Pointer While Typing"
Far as I know, there's no way to do that. Even after turning off the Windows "Hide Pointer While Typing" setting, the cursor will disappear if it is positioned over not just the textbox, but the entire form.
There doesn't seem to be anything in the properties of either the textbox control or the form that affects this behaviour.
My code to display tooltip on mousehover is as follows
e.Node.ToolTipText = Convert.ToString(sb);
But this is displaying with the default color yellow. Can i change this to some other color. I did not find any property for that . If possible can any one give me an idea...
Thanks & Regards,
M.Dorababu.
The background color for a tool tip is a system color setting, you cannot reasonably change that setting. You can alter the appearance yourself by setting the ToolTip.DrawMode property. A good example of the Draw event handler you'll need is in the MSDN library topic for that event.
The next obstacle is definitely the harder one. The tooltip control that displays tips for nodes is built into the native Windows control, you cannot replace it. You'll have to give up on the TreeNode.ToolTipText property and store it elsewhere. Like the Tag property, or generate it on-the-fly.
Then you need to wire into the TreeView's MouseMove event and use its HitTest() method to find out where the mouse is located. Toggle a Timer's Enabled property when the mouse is moved. Use the Tick event to call the ToolTip.Show() method. And wire MouseLeave to turn everything off.
Quite possible, falls in the "when there's a will, there's a way" category.
There is no standard property for that. And for good reason: The colour of the tooltip is none of your business, it’s up to the user. If you really want to work against established practices and reduce the quality of your software for no reason other than to be different, then you’ll have to create your own tooltip component. Otherwise, you should stick with the default.
I'm new to WPF so I've got a problem:
I need to create a grid. This grid should contain a column with a kind of thumbnails.
When I move mouse over a thumbnail, there should appear a panel with a big image. This panel will cover all grid.
But this will make thumbnail think that mouse already has gone.
After mouse's gone, panel should dissappear. Mouse appears above thumb again, and panel appears. And again, and again. I don't know how to handle this.
Could anybody suggest any solution?
Sounds to me like you want to use IsHitTestVisible="False" on the image that pops up. This will make it ignore the popup when testing where the mouse is, so it will think your mouse is still over the thumbnail image. This should work on any UI element, except windows.
Use MouseEnter and MouseLeave:
http://www.hanselman.com/blog/MouseEnterAndMouseLeaveLoopsInWPF.aspx
There are two ways I can think of to do this, depending on what kind of functionality you're looking for.
If you want the larger image to appear in proximity to the mouse and the thumbnail, then you might want to take a look at using a Tooltip.
Otherwise as Aliostad mentioned above, you could use the MouseEnter and MouseLeave events to trigger the display of whatever content is needed.