Request: ComponentPeer Listener


#1

I’ve been working on an accessibility module for JUCE as I mentioned I would a few days ago. It’s going great, and I’m just about done with a macOS backend (to a shared frontend interface, of course). However, I’ve hit a roadblock.

The lowest common denominator implementation across the platforms I’m supporting (macOS, iOS, Windows) is that accessibility regions are defined in screen space rather than app space. This currently doesn’t work for me because there’s no way of being informed when a ComponentPeer's state changes - i.e. when it is moved, resized, etc. It’s not enough to listen to the represented Component either, since it technically isn’t moving around in its parent space and therefore doesn’t produce any ComponentListener notifications.

Can we get a ComponentPeer::Listener that can be informed of window events i.e. minimization, movement around the desktop, resizing, etc? I feel like this has a massive number of useful applications outside my needs for this accessibility module.


#2

Bump… looking for discussion, thoughts, an alternative, or maybe confirmation it’s been seen by the JUCE team… :slight_smile:


#3

The thing about ComponentPeers is that they were never intended to be something that user code would interact with directly. They’re just shadowy objects that hang around in the background, reflecting the state of a Component.

If you want to get really detailed callbacks when a component is moved, perhaps the ComponentMovementWatcher would do the job?


#4

Well the thing is that I don’t want notifications for when Component movement happens relative to a parent ComponentPeer, but when the ComponentPeer itself changes - i.e. is moved relative to its “parent”, presumably the desktop.

I would argue that a ComponentPeer::Listener would still be useful for advanced users who are trying to push the limits of the framework itself to non destructively (i.e. not modifying core JUCE code) add behavior like I’m doing here by getting desktop-level change notifications. Of course this thinking could get out of hand quickly, but I don’t think this is one of those times.

That said, ComponentMovementWatcher may give me enough to work with via the componentPeerChanged() method, assuming it fires whenever the peer moves or is resized… it’s an interesting corner of JUCE I haven’t seen before.

Unfortunately my semester has started, so I have to put the accessibility module on hold. When I get the time to try out ComponentMovementWatcher I’ll report back. Thanks for the tip!


#5

Yeah, this is the kind of thing that the ComponentMovementWatcher should give you.