Comments (4)
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.
Related Issues (20)
- `delay` is not respected with `runComposeUiTest` HOT 1
- compile WasmJs FAILED HOT 2
- [Regression] - running iOSApp fails with 1.6.10-rc02 HOT 18
- CI build task failed after import WASM/JS target HOT 4
- Make the generated resource accessors public HOT 2
- Build failed when building native macOS app after added compose resources. HOT 1
- Encountered error after upgrading from 1.6.10-beta01 to 1.6.10-rc01 HOT 4
- Cannot boot for Desktop after upgrade to 1.6.10* HOT 4
- When will proguard be upgraded to 7.4? It seems that it cannot support jdk 21 now. HOT 2
- iOS - Scroll does not work at all when touch starts on a UIKitView inside eg a LazyColumn HOT 9
- Link issue on iOS (undefined symbol _OBJC_CLASS_$_UITextLoupeSession) with 1.6.10-rc03 HOT 1
- Request for ability to opt-out of resource tasks added in latest compose plugin (1.6.10-rc03) HOT 2
- Request for opting out of generating skiko wasm / js resources in latest compose plugin (1.6.10-rc03)
- Material3 Icon and Text vertical alignment is abnormal. HOT 1
- Support 1Password Universal Autofill on Mac
- RuntimeError: illegal cast for wasmJs with SparseArrayCompat.internalGet
- Android Composables not transformed by compiler in 1.6.10 HOT 5
- 1.6.10-rc03 version error HOT 3
- 1.6.10: MPP with JS but without WASM target: Cannot determine the version of Skiko for Compose '1.6.10 HOT 5
- Compose for Desktop doesn't emit lifecycle events, only states HOT 4
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.