Monitor mouse and key board events

I am trying to track mouse events in RemObject c#, for OSX Application. For this I tried the solution below but it does not work. Can you tell me how is it work

public override void windowDidLoad()
		{
			base.windowDidLoad();
			
			NSEvent.addGlobalMonitorForEventsMatchingMask(NSEvent.EventTypeMask.KeyDown) handler(eventMonitorHandler);
		}

		private void eventMonitorHandler(NSEvent e)
		{			
			Swift.print(e.type);
		}

Hmm, this looks correct, but i can’t get it to work, either

however if I change the event type to Any, I do get MouseMoved (and only MouseMoved) events… this seems to be something that’s broken on OS level, not specific to Elements, as I see many questions about this on Google, and no solutions.

            NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.Any) handler(( @event) => {
                Log($"pressed! {@event}");
            });

Hi, as you mentioned in your reply that might be this OS level issue therefore I have no way but to test it in swift. I have written a small program for macos which useses the NSEvent.addGlobalMonitorForEvents and I was able to capture all the events.

So, my question is that why it is not working in Elements.

EventTest.zip (37.9 KB)

Strange. I coped your exact code over to Elements (attached), and I see only mouse events, yet I can confirm in the Xcode version I see keyboard events too…

MacApp4 1.bugreport.zip (512.0 KB)

~> Process MacApp4 started, took 0.155.
2022-09-29 11:13:38.971889-0400 MacApp4[95227:9250855] global event monitor: 1
mouse event raised
2022-09-29 11:13:39.098117-0400 MacApp4[95227:9250855] global event monitor: 2
mouse event raised
2022-09-29 11:13:39.106421-0400 MacApp4[95227:9250855] global event monitor: 3
mouse event raised
2022-09-29 11:13:39.114607-0400 MacApp4[95227:9250855] global event monitor: 4
mouse event raised

if I print out the value of mask, its 5164 (0x142C) in both versions. I really don’t get what the difference could be, sorry :(.