Hello guys,
I’m migrate one project ( RS to XOJO ) and came across an error, I put two TextFields TXT1 and TXT2 and send a copy of the text of the TXT1 in TXT2 but TXT2 has a me.limittext = 3 ( Open and Text Change events ) and Cocoa does not work in Carbon Yes, I think this is a “Bug”, a suggestion or explanation of why this happens?
Then change that if it’s not what you want.
Huh?
TXT2 have text limit ( me.LimitText=3 )
Carbon Works fine, Cocoa NO !
If I type in the textfield works, but capturing the other textfield not!
[quote=123322:@Paulo Vargas]TXT2 have text limit ( me.LimitText=3 )
Carbon Works fine, Cocoa NO !
If I type in the textfield works, but capturing the other textfield not![/quote]
Paulo, you are not explaining clearly.
Let me see if I sort of understand.
- You have two textfields, TXT1 and TXT2
- TXT2 has a limitext = 3
- In TXT1.text, you have a longer than 3 text, for instance “yada”
- You do TXT2.text = TXT1.text
- Instead of having “yad” in TXT2, you have “yada” and think it is a bug.
LimitText is for entries through the keyboard. If you set yourself by code the content of TXT2.Text, you may have your reasons to make it longer.
The solution is to add this code in TXT2 TextChange
if len(me.text)>me.LimitText then
me.text = left(me.text,me.LimitText)
end if
Hi Michael,
Sorry, this is exactly what you wrote, is that sometimes the google translator commits some errors that I do not go and check the text gets weird.
Thank you for your help, your solution works, but my question is why such a simple thing just does not work on Carbon to Cocoa, it is normal ?
Paulo, I am sorry to disagree, but I tested the very same test program compiling for Carbon, and the behavior is the same: LimitText works only for keyboard input. Xojo 2014R2.1. It may have been different in RS, I do not feel like testing.
I believe when you set yourself the content of the Text property, it is not the same as entry control. LimitText is just like Mask, a way to insure the user will not enter the wrong data. When you modify the property yourself, there are no reasons why data entry control should interfere. At least, I think this is the philosophy behind that.
Michael, I tested again here and without the code You suggested in Carbon Works and Cocoa does not work, I’m using Xojo 2014 R2.1
Inconsistent behavior sounds like a great reason to stop using Carbon.
Tim, Sorry but the inconsistent behavior is not in Carbon, but in COCOA!
I am migrating my projects but with this type of complication takes a long time to move all.
I do not understand. But that is not important.
What is important is to make your new project work.
How long did it take to find you a solution to the TextField issue, Paulo ? I am confident you will succeed.
Hello Michael,
It did not take too much, but it has quite a lot because I have 5 softwares to migrate and many things are not so simple, anyway the help of friends like you, Norman Palardy, Dave S, Tom Iwaniec and others make me go faster and have confidence that everything will be solved soon.
Thanks for all your support!
I think there is an issue with LimitText and Mask. A TextField input with LimitText set does indeed limit the input. If a Mask is also set on the field the LimitText no longer works.
Steps to reproduce:
- Open new blank desktop app.
- Add TextField to main window; set the ‘LimitText’ value to 5.
- Add another TextField to main window; set the ‘LimitText’ value to 5; set the ‘Mask’ to ‘>’ (Forces uppercase).
- Run app.
Expected behaviour :
Both TextFields should stop allowing input once they contain any 5 characters.
Actual behaviour :
The first TextField (Without Mask set) DOES limit the input to 5 characters.
The second TextField (With Mask set) DOES NOT limit the input to 5 characters.
Not sure if this is exactly what the OP is saying, but it is unexpected.
[quote=123413:@Stephen Thomas]I think there is an issue with LimitText and Mask. A TextField input with LimitText set does indeed limit the input. If a Mask is also set on the field the LimitText no longer works.
Steps to reproduce:
- Open new blank desktop app.
- Add TextField to main window; set the ‘LimitText’ value to 5.
- Add another TextField to main window; set the ‘LimitText’ value to 5; set the ‘Mask’ to ‘>’ (Forces uppercase).
- Run app.
Expected behaviour :
Both TextFields should stop allowing input once they contain any 5 characters.
Actual behaviour :
The first TextField (Without Mask set) DOES limit the input to 5 characters.
The second TextField (With Mask set) DOES NOT limit the input to 5 characters.
Not sure if this is exactly what the OP is saying, but it is unexpected.[/quote]
Brilliant bug report. Easy to reproduce. You should definitely use Feedback with exactly the same text to see that it gets fixed by Xojo.
[quote=123366:@Paulo Vargas]Tim, Sorry but the inconsistent behavior is not in Carbon, but in COCOA!
[/quote]
I hate to contradict you, but after reading Stephen Thomas bug report I had a doubt and consulted the LR at
http://documentation.xojo.com/index.php/TextField.LimitText
It states very clearly :
LimitText works for normal text entry, copy and paste, and drag and drop.
Which means it does not work when setting the property directly. It is not a bug. And if LimitText prevents putting whatever you want in the Text property in Carbon, that is the bug…
I’ve installed the Feedback System for the first time and added the report to an existing one to help back it up a bit.
[quote=123703:@Stephen Thomas]I’ve installed the Feedback System for the first time and added the report to an existing one to help back it up a bit.
:)[/quote]
Congratulations !
eheheheheh Michael, I think it’s great when you contradict me and I’m wrong, besides the more I’m your fan and friend and do and think it’s great that contradicts me when I’m wrong because it makes me grow as a professional !
Tanks !
[quote=123703:@Stephen Thomas]I’ve installed the Feedback System for the first time and added the report to an existing one to help back it up a bit.
:)[/quote]
Tanks for your colabotration Stephen !