Forcing monotype font

ukimiku

Active Member
Licensed User
Longtime User
I have an text edit view the typeface of which is set to "monotype" (non-propotionally spaced). But when the user clicks into it, the Android edit facility opens (together with the soft keyboard), and the font changes.

(How) can I have the user edit with a monotype font exclusively?

Thanks.

Regards,
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
If by MONOTYPE you mean MONOSPACE, I have done the following test on a 7 inch tablet running OS4.03 and another tablet running OS2.2. Both yielded the proper font when typing in the editbox:
Using code:
B4X:
edtTextBox.Typeface=Typeface.MONOSPACE

or the other option, in the designer: Text Style, then Typeface, then select monospace.
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Mahares, thank you.

The problem is not with the edit field. There the typeface is correct: MONOSPACE. But when I edit the text, Android opens some sort of extra window above my app where I can enter text via the soft keyboard. There is the problem: in this edit area, a proportional typeface is used. How can I control that?

Again, thanks.

Regards,
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Android opens some sort of extra window above my app where I can enter text via the soft keyboard
I am sorry I am not sure what you mean by the above quote. If it is another edit text view, it will require the same code for monospace. If it is something else, perhaps someone will pick up on it or you may help by putting a picture of it or explain it in detail so you get some recommendation.
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Thanks for replying. I have attached two screenshots that illustrate the behavior I described. The first screenshot shows the edit field with the correct MONOSPACE typeface. When I click (touch) into this edit field, the soft keyboard pops up and asks me to enter text. But this text, during editing, is NOT in monospace, which it should be, because in the app, the user is supposed to arrange letters exactly below each other.

Thanks.

Regards,
 

Attachments

  • screen1.jpg
    screen1.jpg
    9.7 KB · Views: 174
  • screen2.jpg
    screen2.jpg
    36.3 KB · Views: 193
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Erel, thank you for the code.

But the result is almost the same. I put your code in "Activity_Create", and while I get an additional line at the top of the screen (so full screen mode is gone), the typeface in the editing facility changes to a proportional one. By the way: this is on ICS 4.0.4.

Regards,
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It works fine here on 4.1:
SS-2012-08-14_11.12.15.png


B4X:
Sub Globals
   Dim et As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
   et.Initialize("")
   et.SingleLine = False
   et.Typeface = Typeface.MONOSPACE
   et.Gravity = Bit.Or(Gravity.TOP , Gravity.LEFT)
   Activity.AddView(et, 10dip, 10dip, 250dip, 140dip)
   Dim r As Reflector
   r.Target = et
   r.RunMethod2("setImeOptions", 0x10000000, "java.lang.int")
End Sub
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Thank you for the code. Unfortunately, it still isn't working for me. Maybe it has to do with the fact that my App only works in landscape orientation? In addition, I find that not using full screen mode is disadvantageous for my App. Using full screen, is there another method to force the MONOSPACE typeface? (I don't understand at all why the screen mode should influence the typeface used by the text editor. To me, they are rather unrelated entities. Why is that?)

Thank you.

Regards,
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
I created a new project and used your code.
It is working in a new project! I turned full screen mode on, and it is still working! That is great news.

In my App, however, it is not working. Maybe because I didn't add the edit text view via the designer, not programmatically? I will test that.

In my App, there is a panel that used to be above the edit text. Then I used et.BringToFront, because the monospace font was not working, but without success. Does that give any hints?

Thank you for staying with me on this one.

Regards,
 
Last edited:
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Screenshots

The screenshot.
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
That screenshot was too large (1280 pixels wide) for the forum. Here you go...
 

Attachments

  • monofull.jpg
    monofull.jpg
    9.8 KB · Views: 169
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Solved

Erel, thank you. Problem solved. I had called the reflector method on the edit text before I brought it to the front. Now I have changed the order, and it works flawlessly, even in full-screen mode! That was quite important to my App, since the user enters program code in that edit field, which must be aligned by the monospace typeface sometimes.

:sign0098:

Regards
 
Last edited:
Upvote 0
Top