Open jbflow opened 4 years ago
OK I figured it out - using setattr ('AXSelectedChildren', AXUIElement.ref)
Don't know if that's the best way but it works.
Try using x.AXSelectedChildren = AXUIElement.ref
__setattr__
is supposed to be called when you try do to that. python docs
__setattr__
definition checks if it's an AX attribute
https://github.com/daveenguyen/atomacos/blob/master/atomacos/_a11y.py#L82
Yeah that was the first thing I tried, I thought that was the case but for some reason it doesn't work. No error or anything, it appears to work, but doesn't do what is expected in the GUI. I was really trying to understand the functioning by looking at ApplicationServices and seeing what I needed to pass to AXUIElementSetAttributeValue when I came across this and thought I'd try it. I wasn't really expecting it to work tbh.
OK it was my mistake, I needed to do it like this x.AXSelectedChildren = [AXUIElement.ref]
and also I have to use a direct reference to the AXUIElement, when it's stored in a variable it doesn't work.
So if I store the list of AXChildren as a variable and then try to set AXSelectedChildren from that list using the index it just doesn't do anything, it has to be set from the original element and AXChildren[x].ref. I guess that's something to do with how the Accessibility stuff works?
I think as long as value you give is a CFTypeRef
based on the apple docs.
Not sure what makes something CFTypeRef.
Probably something that comes from objc
library calls.
.ref
are original reference to objects from objc
, I believe.
https://github.com/daveenguyen/atomacos/blob/master/atomacos/_a11y.py#L259 https://github.com/daveenguyen/atomacos/blob/d520135ff03ba548140dec07bd1b4ef2a2ae0e5c/atomacos/_macos.py#L142
Trying to figure out how to set the selectedchildren attribute of an object.
I know in Obj-C it's AXUIElementSetAttributeValue, but can't figure out how to do it with this.