Make the cursor stay on a specific point - amcharts

Is there any way to get the ChartCursor to stay on a selected point? Especially while using touch-devices it's very uncomfortable, that you have to constantly touch the right data point to see the actual values. Regarding huge datasets the cursor starts to select immediately if you move just a bit and hit the next datapoint. And while you make a selection the cursor disappears.
Is there some kind of workaround to get the cursor stay, where the graph ist clicked/tapped? (Or at least a way to use some kind of threshold for the select?)

Related

How to track mouse movements without limiting it to screen size?

I'm using WM_MOUSEMOVE to get changes in mouse position. When simulating "knobs" for example it's desired to let the user go up/down with mouse without any limits. In this cases I hide cursor and use SetCursorPos to change its position every time user moves with it and detect just the difference from the original position.
Unfortunately it doesn't seem to work - if I set the mouse position, it sometimes works, but sometimes is one or more pixels away, which is just wrong. And even bigger trouble is that after the call another WM_MOUSEMOVE seems to be delivered, which unfortunately does the same thing as it wants to move the cursor back to the original position again. So it ends up in an infinite cycle or settings mouse position and receiving messages until the user releases the mouse button.
What's the correct approach or what's the problem?
The raw input system can do this - it lets you register for raw mouse input that isn't clipped or confined to the screen boundaries.
Broadly speaking, you register for raw input using RegisterRawInputDevices(). Your window will then receive WM_INPUT messages, which you process using the GetRawInputData() function.
See Using Raw Input for an example.
I hide cursor and use SetCursorPos to change its position every time user moves with it and detect just the difference from the original position.
This is just plain wrong. Instead, use SetCapture() to capture the mouse. All movements will be reported as WM_MOUSEMOVE messages with coordinates that are relative to the specified window, even if the mouse is outside of that window, until you release the capture.
Asking the user to move the mouse continuously, even after the cursor hit the screen limit is a very bad idea in terms of User Interface, IMHO.
Some games have another approach: when the mouse hit the "limit", the game enter a special mode: things appears to function exactly as if the mouse was moving, even if the user don't move it. When the user wants to exit that mode, he just has to move the mouse of the limit.
Doing so requires a timer, armed when the mouse hit some limit, executing code periodically as if the mouse was moving. The timer is stopped when a real mouse movement makes it leaves the limit.
Ok folks, so I found a solution simple enough:
The main problem is that SetCursorPos may not set the coordinates accurately, I guess it's because of some high resolution processing, nevertheless it's probably a bug. Anyway if SetCursorPos doesn't set the coordinates correctly (but +-1 in x and/or y) it also sends WM_MOUSEMOVE to the target window. As a result the window performs the exact same operation as before and this goes on and on.
So the solution is to remove all WM_MOUSEMOVE messages right after SetCursorPos:
MSG msg;
while (::PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) { };
Then retrieving the current mouse cursor pos using ::GetCursorPos .
It's ugly but seems to fix the problem. It basically seems that in some position of the mouse, the system always adds or subtracts 1 in either coordinate, so this way you let system do the weird stuff and use the new coordinates without trying to persuade system that your coordinates are the correct ones :).

obtaining MOUSE_DX MOUSE_DY in winapi

I need obtain a MOUSE_DX and MOUSE_DY values where
MOUSE_DX is a difference between MOUSE_X and MOUSE_PREV_X
someone give stupid answer to my that i can hide cursor substract
succesive MOUSE_X between mouse move events, and when cursor
goes away from the centre of the sceen call ShowCursorPost to the
cantre of the screen - but this is a real hell : it is stupid perself also
calling ShowCursorPost generate fake mouse move events so
then I would need to filter out this fake movements then (It is hell)
Is there some more reasonable way of obtaining the MOUSE_DX
MOUSE_DY I need?
//EDIT (more explaining for questions )
I want to use mouse as a steering device - something like mowing yaw/pitch/roll of the camera
For this purpose I need to gest something like MOUSE_DELTA_X MOUSE_DELTA_Y
where such numbers are indeed the MOUSE_X-MOUSE_PREV_X where MOUSE_X/Y are
coordinates of the mouse cursor given to me by WM_MOUSEMOVE
allright - this works to some extent but not much:
I need the DX DY walues related to mouse movements but do not need
a mouse cursor at all, when mouse cursor hits the screen edge i will
not gest full DX but some cutted and then all zeros
To prevent this i call (as somebody advice me) SetCursorPos when
the cursor nears to the edge of the desktop (the window really becouse
I do not want him to exit my window) then I call SetCursorPos
to the centre of the client area (I also make cursor invisible, and
also clip it to the window size but it also brings a lot of
trouble, need to unclip the areo on alt+tab etc it is all tiresome
and it is all a complex workaround for such simple thing like obtaining
DX DY) I just do not need this f*cking invisible cursor moving on screen
at all here - but I need mouse DX DY only
but let assume that this machinery with invisible cursor is tiresomely
coded and debugged
the other trouble is that when I call SetCursorPos It also generates
fake mouse movement backward and it generates fake DX and DY then
(it is hard to filter - at least i do not know how to do it all
in a robust way)
(can this fake mouse move been easily filtered out?)
I did it all this invisible cursor clipping SetCursorPos and filtering
out the false DX DY but it is very ugly thing very error prone and
confusing - all this for simple obtaining (cursor independant/mouse
related)DX DY for every move - this is hell It made me a long hours to
debug this stuff so I am angry - this is coding hell - this is terribly
wrong so I am angry and need a good way of doing it
The WM_MOUSEMOVE event tells you the current position of the cursor. Well, it's actually the position of the cursor when the event was placed in the message queue, not quite the same thing. But the system does not keep track of the position of the cursor associated with the previous WM_MOUSEMOVE message. From this you can conclude that you will need to keep track of that.
So, do the following:
Declare variables to hold the previous cursor position.
Initialize those variables to the current cursor position.
Whenever you process WM_MOUSEMOVE you can compare the current position with the previous.
Once you have done that, update the previous cursor position to be equal to the current position, ready for the next WM_MOUSEMOVE message.
What you could try:
Use the ClipCursor function to confine the cursor inside your window, or a sub-rect.
When the mouse hit your "border", start a timer. Stop the timer when the mouse leaves the border.
On each timer tick, you could generate a fake DX or DY.
The idea is to have the behavior of many games: you move the mouse, hitting a border, and then all behave as if you were still moving the mouse.

Set the cursor, bypassing cursor magnification

I'd like to set the cursor in a Mac application for a specific view without that cursor being subject to the Cursor Magnification setting in Universal Access.
As an example, I'd like to set the cursor to a preview of the brush the user has selected. It should be the size of the brush, so that the user knows what how big their brush-stroke will be. Cursor magnification throws this off; I might as well just have the arrow cursor at that point.
I do not want to change (and have to restore) the cursor magnification setting itself. I want specific custom cursors to not be subject to it.
Hiding the cursor and drawing a fake cursor within my view doesn't work, since it'll be clipped at the view/window edges.
I'd prefer a solution that lets me use NSCursor, but seeing no obvious solution in that class, I'd be willing to accept another solution that uses something lower-level.
Hiding the cursor and drawing a fake cursor within my view doesn't work, since it'll be clipped at the view/window edges.
Then an overlay window is your next best bet, I think.

How to tell if mouse pointer icon changed

I'm writing a screen recording app for Windows in Delphi 7 and wish to know when the mouse pointer changes in my app (like from a normal pointer to a resize pointer, etc).
Currently what I'm doing is painting the mouse pointer onto an in-memory bitmap everytime the mouse moves (and on a timer) and doing a pixel by pixel comparison of it with the last bitmap I painted.
Though the comparision is fairly quick (about 2-5ms) because it's happening so often (every mouse move) it adds up. I figure there has to be a faster and less complicated way!
You have a handle to the cursor, right? If it's the same handle value you had before, then I think it's reasonable to assume it looks the same, too. If the cursor looks different, it will have a different handle value.
That should certainly be true for the standard system cursors. If the application you're recording is creating new cursors while it's running, then maybe it would be able to update the appearance of the current cursor without actually making a new cursor object in the OS (and thus keeping the same handle value), but I don't think that's likely, especially since SetCursor exits immediately when the cursor hasn't changed, and I expect the API function doesn't do the graphical comparison you're trying to avoid, either. It just compares the HCursor value.

Win32 WM_SETCURSOR, WM_MOUSEMOVE always in pair?

I'm working on a Win32 control. There could be hundreds of "items" on this control. Those are not windows, but internal objects (eg: rectangles). Depending on the mouse position I want to change the mouse cursor. That is fine, I can use WM_SETCURSOR.
At the same time based on mouse move I want to display a status bar which shows details about the object currently under the mouse. For that I can use WM_MOUSEMOVE.
Because there could be hundreds of items, traveling all of them to find one under the mouse, well it's not efficient, especially two times (one for set cursor, one for mouse move).
To make it short, do you know if WM_SETCURSOR and WM_MOUSEMOVE are ALWAYS in pair? In that case I can calculate what I want during WM_SETCURSOR. The other option would be to set the mouse cursor during WM_MOUSEMOVE, but as far as I know that it's not a good solution (will flicker).
Thanks
While they might currently always come as a matched pair, you probably can't rely on this behaviour.
You can set the cursor during WM_MOUSEMOVE (using SetCursor), and it won't flicker, as long as (IIRC), you return TRUE from WM_SETCURSOR without doing anything (i.e. you eat the message), and your window doesn't have a class cursor assigned to it.
You might also try GetMessagePos() (gives cursor screen coordinates), then MapWindowPoints() and see if it's in hot rectangle, or something similar.
Most important of all is that your window message handlers shouldn't worry about holding or calculating anything. You should simply signal your application's logic that the mouse is potentially over new area and make it find the object(s). Once you find the hot area (or more than one), cache its (their) boundaries and check the following mouse moves against those. Once the mouse moves out from one of them, you can rebuild your hot-object-list.
You don't have to be hunting for the hot area all over the control on every mouse move.
In case when there can be many objects sharing the same area, there's the question of z-order. Think about it when you're creating those objects and handle their movement.
Also you should think about an efficient data structure holding the object coordinates so you don't have to check every single object every time you're looking for the hot one.
Just my two euros. ;)
Is there any way to cache the last item that was found, and shortcut the lookup if the cursor is in the same place? That would be the most robust solution.

Resources