Android Question [B4X] Issues with B4XFloatTextField

Status
Not open for further replies.

MrKim

Well-Known Member
Licensed User
Longtime User
I have been told this is the future and I am trying very hard to use it, I rally am.
But I have been trying to fix this for 4 hours....
Setting Text alignment in the designer does not appear to have any affect.
I have a single line B4XFloatTextField that I would like to right align I have the Alignment set to CENTER_RIGHT in the designer but it still aligns left.
The following line sets RIGHT alignment in B4A:
FloatTxt1.TextField.SetTextAlignment("CENTER", "RIGHT")
But that line fails in B4J with the following error:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 446 (B4XFloatTextField)
java.lang.RuntimeException: Type does not match (class javafx.scene.control.TextField)
    at anywheresoftware.b4a.objects.B4XViewWrapper.typeDoesNotMatch(B4XViewWrapper.java:573)
    at anywheresoftware.b4a.objects.B4XViewWrapper.SetTextAlignment(B4XViewWrapper.java:448)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:676)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:64)
    at b4j.example.b4xmainpage._b4xpage_created(b4xmainpage.java:58)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:115)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:477)
    at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:868)
    at b4j.example.b4xpagesmanager._showpage(b4xpagesmanager.java:347)
    at b4j.example.b4xpagesmanager._addpage(b4xpagesmanager.java:176)
    at b4j.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:190)
    at b4j.example.b4xpagesmanager._initialize(b4xpagesmanager.java:126)
    at b4j.example.main._appstart(main.java:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)
So I have been unable to align text to the right in B4j

I also have a multiline B4XFloatTextField
It starts with text in the upper left corner exactly as I want - regardless of how I set the Alignment property.
1629813335671.png

I would PREFER that the text NOT wrap - but it does, regardless of how I set Wrap Property.

In B4A, for some reason, a multiline B4XFloatTextField defaults to the text always starting out LEFT CENTERED, and then the first line of text moves UP as you add new lines.
Again, setting Horizontal Alignment and Vertical Alignment in designer seemed to have absolutely no affect.
I also found myself messing around with the single line / multiline settings there are TWO in the B4A designer one under text properties called 'Single Line', and another under custom properties CALLED 'Multiline' I thought perhaps some combination of these would prevent word wrap but it does not appear to be the case.
I was finally able to get the text to the top left with:
B4X:
    #If B4A
        Note.TextField.SetTextAlignment("TOP", "LEFT")
    #End If
but I am still looking for a way to right align text in B4J.
I haven't gotten to B4i yet.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. You should post it in B4J questions.
2. Out of the box, B4XFloatTextField doesn't support changing the text alignment (which is quite rare with input fields).

Due to historic reasons the designer shows all properties with custom views. Wrap and alignment properties doesn't do anything with B4XFloatTextField.

In B4A, for some reason, a multiline B4XFloatTextField defaults to the text always starting out LEFT CENTERED, and then the first line of text moves UP as you add new lines.
This is how the native EditText behaves.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
1. You should post it in B4J questions.
2. Out of the box, B4XFloatTextField doesn't support changing the text alignment (which is quite rare with input fields).

Due to historic reasons the designer shows all properties with custom views. Wrap and alignment properties doesn't do anything with B4XFloatTextField.


This is how the native EditText behaves.
Yes, I should moved it. My bigger problem was with the B4A multiline starting in the middle of the page but I solved that on while I was in the process of writing this missive.
As to it not being available - how would we know that - the property is there, and it works in one environment, but not another? You HAVE done a wonderful job in terms of making things work J/A/i. I and in Basic no less! My native tongue šŸ˜„. But is extremely frustrating not knowing what works and what doesn't. More than once my design decisions have had to change because it turned out something I thought would work on al three platforms, didn't.

Think I am going to put in a wish for a properties page for, at the least, the xui.views like B4XFloatTextField each view would need three listings one for each language.

I definitely relate, @Erel. It is much more fun to write new stuff than document the old. It is my bane as well.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I definitely relate, @Erel. It is much more fun to write new stuff than document the old. It is my bane as well.
Please don't make such statements about me. I've tried to explain that there is a technical limitation with custom views where the "text" properties always appear. The technical limitation can be improved but it has nothing to do with anything else you wrote.
 
Upvote 0
Status
Not open for further replies.
Top