Comments (6)
Can you provide a complete example of the problem? This works correctly for me:
fun main() = SwingUtilities.invokeLater {
val frame = JFrame()
frame.contentPane.add(ComposePanel().also {
it.setContent {
Column {
Text("Hello World")
Button(onClick = { println("Click") }) {
Text("Click me!")
}
}
}
})
frame.size = Dimension(400, 500)
frame.isVisible = true
}
The accessible is not exposed via ComposePanel
, but via skiko's HardwareLayer
:
internal open class HardwareLayer(
externalAccessibleFactory: ((Component) -> Accessible)? = null
) : Canvas() {
private val _externalAccessible = externalAccessibleFactory?.invoke(this)
override fun getAccessibleContext(): AccessibleContext {
val res = (_focusedAccessible ?: _externalAccessible)?.accessibleContext
return res ?: super.getAccessibleContext()
}
}
from compose-multiplatform.
I don't quite understand what HardwareLayer
is about, but what I am trying to say is that I believe ComposePanel
should behave the same way as a JPanel
, i.e. it exposes the components it contains as Accessible
through its implementation of getAccessbleContext
. Here is the JPanel
implementation:
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJPanel();
}
return accessibleContext;
}
protected class AccessibleJPanel extends AccessibleJComponent {
protected AccessibleJPanel() {}
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PANEL;
}
// getAccessibleChildCount and getAccessibleChild are inherited from JComponent, and the
// inherited implementation looks at the list of child component:
int getAccessibleChildrenCount() { // Inherited from Container.java
synchronized (getTreeLock()) {
int count = 0;
Component[] children = this.getComponents();
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof Accessible) {
count++;
}
}
return count;
}
}
}
The reason it is important to link parent and children is that it is an expectation of the Java Access Bridge API (and screen readers using the API) that there is a top down Accessible
tree that can be used to traverse all UI elements from the top level window (JFrame) to any element displayed in that frame. With the current implementation of ComposePanel
, the Accessible
tree stops at ComposePanel
, and the container does not have the ability (afaik) to expose the sub-tree of Compose components it contains.
The use case we are looking is an IJ plugin (Android Studio) embedding a ComposePanel
in a IJ platform ToolWindow
. With the current implementation of ComposePanel
, the Accessible
tree is incomplete, i.e. the traversal "stops" at the ToolWindow
container, and nothing is exposed via ComposePanel
.
from compose-multiplatform.
Can you provide a small reproducer app for this?
from compose-multiplatform.
@m-sasha, this is a bug from IntelliJ/Android Studio integration. It probably uses System.setProperty("compose.layers.type", "COMPONENT")
. Could you try it with it?
from compose-multiplatform.
Should this be reopened considering the PR didn't actually fix the issue for Windows and macOS?
from compose-multiplatform.
The remaining issues have been fixed in separate PRs. If you're still seeing the problem reported here, let us know.
from compose-multiplatform.
Related Issues (20)
- Preview in commonMain? HOT 2
- [1.7.0-alpha01] Cannot change attributes of dependency configuration ':debugFrameworkIosArm64' after it has been resolved HOT 9
- I have an issue with a common ViewModel and navigation in my Compose Multiplatform application HOT 3
- Ios crash while using textMeasurer.measure inside Dispatchers.Default HOT 17
- CompositionLocalProvider related RuntimeError: illegal cast HOT 7
- Compose navigation crash v2.8.0-alpha08 (UnsatisfiedLinkError) HOT 5
- Support common `org.jetbrains.compose.ui.tooling.preview.Preview` in IDEA and Android Studio HOT 17
- ShadowJar Executable HOT 2
- Error: self-signed certificate in certificate chain HOT 5
- Improved window sizing API (Windows) HOT 3
- `const auctionConfig = { HOT 6
- Google chrome HOT 3
- Chrome web store HOT 3
- Chrome web store developer support HOT 2
- iOS Keyboard Broken with `readOnly` will show/hide in loop HOT 13
- iOS: ModalBottomSheet can't ignore safeArea HOT 2
- Unable to run tests using Multiplatform Resources HOT 2
- Make AnnotatedString.Companion.fromHtml available to multiplatform HOT 3
- [WASM] Custom Font Text flickering from tofu to the actual text with the right font HOT 4
- Previewing fails with AssertionError: Data is too big HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-multiplatform.