How to set the cursor in kEventControlSetCursor? - macos

I want to be able to change the appearance of the mouse cursor as it moves over various hot spots in my view's and it seems to me that I should be doing that in the kEventControlSetCursor handler (which I can get). The function "SetCursor" is deprecated, which leads to the question, what do I call to actually change the cursor?
And is there some standard list of cursors I can use? Things like horizontal and vertical arrows? I beam?

Use SetThemeCursor or SetAnimatedThemeCursor, which are both part of the Appearance Manager.
And is there some standard list of cursors I can use? Things like horizontal and vertical arrows? I beam?
The standard cursors, including those, are all you can use in the Appearance Manager; it provides no way to set a custom cursor.
The modern replacement for all three functions is Cocoa's NSCursor, which provides standard cursors and supports custom cursors.

Related

Is there a standard way to create "combined" Windows cursors (e.g. Arrow+Stop)

It is well known that the WinAPI offers a number of default cursors. Among these, there is for example the default arrow (IDC_ARROW) and a "stop" icon (IDC_NO).
When using drag'n'drop in the Windows Explorer (e.g. in Windows 7), you can notice that Windows shows a combination of the two aforementioned cursors when dragging a file to some place where it cannot be dropped. This cursor does not exist as a .cur file and it cannot be configured in Windows' mouse setup.
I didn't stumble upon any obvious function to "combine" cursors, so I'm wondering if there's a default way in the WinAPI to create a cursor like the one in the example, or if I have to toy around with the two cursors manually and blit them together into a new cursor on my own.

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 implement a threaded view?

I need to implement a threaded view of sorts in an old VB6 app. It should look similar to this:
So, it's like a TreeView of sorts but there are buttons on the right (for each row) that could be pressed. The view does not need to collapse - it always stays in the expanded mode. The users should be able to respond to each node (via the comment button on the far right). And, of course, users should be able to scroll through the entries.
What are some of the ways I could implement this? I am open to 3rd party controls, paid or not.
VSFlexGrid has an outline mode. You can set the indent per row via the RowOutlineLevel property. It supports word wrap, images, etc within its cells/columns so you should be able to get pretty close to what you want. It also supports owner-drawn which lets you fully customize the cell painting (for example, to get those rounded corners).
I'm sure there are other controls out there as well...

Multiple mouse/mice/cursor?

How can I show another cursor for multiple mice?
I have two TMemos, two keyboards which can type into their respective TMemo, 2 mice and I need 2 cursors those.
If hypothetically, I can already detect which mouse is which. How can I make my own cursor to go along with it. (using Delphi)
Possibly along the lines of Multipoint
as an alternative, is there any software which can render more that one cursor. Like CPNMouse?
EDIT:
I found that I can use the mouse_event Function in windows, but I still don't have the visual representation of the cursor.
Cursors are just resources. Here is a good list of the standard cursors that can be used. TControl Defines a cursor property that can be set to the cursor that should be used when over a given control. You can also use Screen.Cursor to control the entire application cursor.
To define a custom cursor you use the following code.
{$R MyCustomCursors.RES}
const
crCustom1 = 1;
crCustom2 = 2;
...
Screen.Cursors[crCustom1] := LoadCursor(hInstance, 'CUSTOM1');
Screen.Cursors[crCustom2] := LoadCursor(hInstance, 'CUSTOM2');
...
Delphi was not designed by default to deal with multiple mouse pointers, but the I suspect most environments are not. The SDK you mention is the only source of information I have seen on using multiple mice at the same time in a single application. It however is .NET only, so using it would require Delphi Prism.
If you want to roll your own support for multiple mice the same trick of using WM_INPUT can can be used. Windows will treat both mice as the same. You will have to do custom painting of the mouse cursor by hand for the second mouse.
Windows doesn't support multiple mouse or keyboards. Since each process have only 1 input queue, Windows treats all similar input devices as the same single device. This can't be changed. End of story. Period.
But even if you can't do this on system wide scale - you still can do this in one particular application. You need to write a special driver and install it for the second mouse only. This driver should not pass mouse movements to usual consumer (input queue), but rather redirect input directly to your application.
You can use a already written drivers - for example, this one or the one, that you've already mentioned.
It can be simulated its action virtually from the original cursor by doing something seamingly fast

Implementing "scrubby sliders" in Cocoa?

How would I go about implementing something along the lines of "scrubby sliders", like in Photoshop and quite a few other image-processing applications?
They are slightly hard to describe.. basically you have a regular numeric input-box, but you can click-and-hold the mouse button, and it functions like a slider (until you release). If you click in the box, you can select text, edit/paste/etc as usual.
The Photoshop docs describe it, and I put together a quick example video (an example of the sliders in Shake)
Another similar implementation would be the jog-wheel in Final Cut Pro, which functions similarly, without the numeric readout being underneath.
I can't seem to find any mention of implementing these, although there is probably alternative names for this. It is for a OS X 10.5 Cocoa application.
It is for a colour-grading application, where a user might need to make tiny adjustments (0.001, for example), to huge adjustments (say, -100 +100) on the same control. A regular slider isn't accurate enough over that range of value.
Copy-and-pasting values into the box would be a secondary concern to scrubbing the values, and the Photoshop/Shake setup really well. The unobviousness of the control is also of a low concern, as it's not a "regular desktop application"
I've encountered those. They suck, because they prevent the user from dragging to select the text of the number.
A better idea would be a miniature slider beneath the field that expands to a full-size slider when the user holds down the mouse button on it and collapses back to its miniature size when the user releases the mouse button. This way, the selection behavior is still available, but you also provide the slider—and in a more obvious way.
There's no built-in class in Cocoa for either one. You'll have to implement your own.
I doubt that this exists in Cocoa framework. As far as I remember it is not mentioned in the Apple Human Interface Guidelines.
You can develop one yourself by using a custom view and tracking mouse events (-mouseDown:, mouseUp:, -mouseDragged:).

Resources