I have a problem I can’t solve:
I wrote quite a big app for my personal accounting needs. I use 2 different list boxes. One of them works fine.
The other one does not accept German Umlaute like ",… or any special character. When I press a special Character I get a system beep (not programmed by me) and the character is not displayed. The “text change event” is not fired even I return False in the Cell key down event. The system beep is produced when ending the Cell key down event routine with return False.
What can I do to find the problem? If somebody can help me -> That would be …
I use Xojo r2017R2.1. I made test’s with newer Xojo releases -> no difference. I have an old version compiled with
Usually, the beep is because you do not handled the Key and no one handle it either.
Try Return True if you handled the key AND no one in the event chain will handle it.
Thank you for your answer. Very kindly!!
Imagine, I use the Cell of the Listbox as an edit fiel to enter Text. Everything works fine except the acceptance of special Characters. As soo as I press the special Character I get the beep. All other Characters are accepted and “displayed” correctly. I do not treat every character it self. Only when I press return I recover the text from the Listbox Cell.
Any other hint?
Create a brand new project, add a Listbox and the two lines from the LR to set a Cell as Editable and add one Row.
Is your trouble still here ?
Nol works fine here (entered in an Editable Cell).
Did you use DefineEncoding or such ?
Finally I have found the cause for the problem! But I still don’t have a workaround.
The problem ist the following Programm line: ActiveCell.Mask = “&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&”
I finally found out, that this Mask limits the Text to 40 characters but does not accept German Umlaute like “,…”.
Is that an error in Xojo or what could be the cause? in a previous, old version (Realbasic 2011) this command worked properly.
-> Any idea? Thanks in advance for your proposal.
Or write your own function using Len
Or use a better Mask character, like aaaaa
, or ???
But in any case read the manual before posting!
This looks like a bug to me: ~+a = ~a in a TextField, not as I expected !
Ok thanks for the hints!
No other Mask Character solved the problem! The behavior was the same.
I finally overcome the Problem with a LEN check in the Key pressed event of the list Box, as Markus proposed. -> Thank everybody for your help!
care to explain a bit more ?
Emile, I guess Claude just wanted to limit the text to 40 characters and be able to type German Umlaute like “,…”, and with LEN check is enough for this.
I understand that, but I do not understand the trouble and how len resolve it from the op question.
Now id the problem appeared at the 39th character, I had an answer, but that was not in the question.
Emile, the OP originally said:
[quote]I use 2 different list boxes. One of them works fine.
The other one does not accept German Umlaute like ",… or any special character.[/quote]
[quote]Finally I have found the cause for the problem! But I still don’t have a workaround.
The problem ist the following Programm line: ActiveCell.Mask = “&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&”[/quote]
After I read that, at least for me, the problem is that no special characters can be entered with that mask and need to limit to 40 characters.
I can’t find a mask character that will work for this situation, so I guess the OP removed the mask (to let special characters work) but use LEN to limit the input to 40 characters or less.
LEN, did not fix the mask problem. As I understand LEN only helped for the 40 character max input and I guess OP removed the mask.
Reading Page Not Found — Xojo documentation
[quote]& - Character or space placeholder. It accepts one character.
Valid values are the ASCII characters 32-126 and the non-ASCII characters 128-255. For example, the mask “&&-99999” accepts “li20520” and returns “li-20520”.[/quote]
I wonder if is character 132, is 148, then why is not possible to enter those with mask &
perhaps this should read “accepts one BYTE”… and some unicode is TWO bytes
Thank you Dave.
I guess that’s the problem. I found a list of extended ascii characters that say that is 132, is 148, but I can’t make Xojo display that on mac. Then I found a different table ascii extended character set for mac.
When I type or into a TextField or string it is coded as UTF8 and that’s two bytes (as you said).
Xojo strings are by default UTF-8.
Extended ASCII is meaningless unless you specify which encoding or code table you use as different computer systems or geographic regions use it for different characters.
This simply does not exists even if you are able to localize some tables of characters with that name in the internet.
ASCII is 0-127.
Now, even with the use of Len, a bug still exists. Why ?
Because to get a
ã you have to type two characters: the
a. So when you have 39 characters and you want to type one with an accent, you will not be able to do that (testings have to be done to confirm that).
Alberto: thank you for your analyze. Now, I understand.
not true… LEN counts a 2byte Unicode as ONE character… LENB would count it as TWO bytes
What Len Count is not the matter. To get
you have to type TWO characters in the keyboard.
I do ot talked about a character as the final operation, but how to get that final operation.
I am at low memory condition, but Xojo is running: I will check right now
As I expected, typing Option-n (to get a tilde: ~) fire a KeyDown event (AZERTY keyboard), so TWO KeyDown Events are needed to get
Emile, two keydown events is something different than two characters.
LEN counts characters.
Please try things first before making statements.
I think Emile is trying to say that having code on KeyDown will mess up the LEN count. Len will be 40 after you press Option-n, and will stay on 40 when you press a after that.
If you have this code on KeyDown:
If Len(Me.Text) = 40 Then Return True
you will end with something like this:
you can’t finish your input of .
Edit: one way to deal with this is using TextChange instead and something like:
If Len(TextField1.Text) > 40 Then
TextField1.Text = TextField1.Text.Left(40)