我试图将com.codename1.components.FloatingActionButton
与com.codename1.ui.TextArea
组合使用。TextArea上的FloatingActionButton按预期工作
现在我有两个问题:
- 显然,VALIGN不兑现 - 它是一个错误吗?
- FloatingActionButton的actionListener未被调用。我的用法有什么问题吗?或者它是一个错误?
这里是展示它的代码:
public class FormFabOnText extends Form {
public FormFabOnText() {
setTitle("FormFabOnText");
setLayout(new BorderLayout());
Container contentPane = getContentPane();
contentPane.add(BorderLayout.NORTH, new SpanLabel(
"This form contains a TextArea and a FloatingActionButton combined by bindFabToContainer. "
+ "It demonstrates that the FloatingActionButton is not working in this constellation."));
TextArea textArea = new TextArea();
float iconDefaultSize = FloatingActionButton.getIconDefaultSize();
try {
FloatingActionButton.setIconDefaultSize(2.0f);
FloatingActionButton floatingActionButton = FloatingActionButton.createFAB(FontImage.MATERIAL_CLEAR);
Container containerFab = floatingActionButton.bindFabToContainer(textArea, Component.RIGHT, Component.CENTER);
floatingActionButton.addActionListener((e) -> textArea.setText(""));
contentPane.add(BorderLayout.CENTER, containerFab);
} finally {
FloatingActionButton.setIconDefaultSize(iconDefaultSize);
}
}
}
看起来像'com.codename1.ui.Container.getComponentAt(int,int)'方法需要对LayeredLayout进行特殊处理 –
显然'调用FloatingActionButton.pointerPressed'和'FloatingActionButton.pointerReleased' - 所以出了什么问题? –
当'TextArea'聚焦时'FloatingActionButton'不起作用,那么'com.codename1.ui.Container.getComponentAt(int,int)'根本不会被调用 –