desktopNSSwitchControlMBS causing recursion errors

@Christian_Schmitz I am using an NSSwitchControl on a popover panel. Selecting it triggers a resizing of the panel which results in moving of the switch during the animation effect of the popover. Since the mouse is still over the switch, this then causes multiple recursions as the Switch detects those movements and crashes the app with an overloaded stack (not caught by Xojo’s IDE).

As you might imagine, it has taken a fair bit of time to deduce the problem but thanks to ChatGPT for some hints.

The question is, is this a bug in desktopMSSwitchControlMBS? Or, do I have to revert to checkboxes?

Edit: Adding an example of the recursion error:

-------- RECURSION LEVEL 37306
13 AppKit 0x1960a527c forwardMethod + 252
14 AppKit 0x1966d422c __39-[NSView(NSTrackingArea) cursorUpdate:]_block_invoke + 52
15 AppKit 0x1966d4194 -[NSView(NSTrackingArea) cursorUpdate:] + 132

Well, my control code is just a tiny layer to host the control. I don’t think we have much code there to interfere.

If I should take al look, you’d have to make a small sample project to show the problem.

Tks. I’m trying other solutions using callLaters, or hiding the control whilst animating, no success yet but will revert.

Solution seem to be:

  1. On switch.action event:
    1. switch.enabled = false
    2. switch.visible = false
  2. Trigger realignment of controls
  3. On realignment complete:
    1. switch.enabled = true
    2. switch.visible = true

Seems to prevent the NSTrackingArea stuff from triggering.

Is there a way of programatically refreshing the NSSwitchControlMBS? Seemingly random sometimes it appears as a grey blob, but still works as a switch.