I’m converting an app from Carbon to Cocoa. It’s a calendar app and uses lots of TextAreas. These don’t use styled text but they do have the MultiLine property set. The user has the option of defaulting the font, font size, text alignment and colour and well as bold, italic and underscore. All works fine under Carbon.
It’s soooo slow under cocoa. A major issue I find is that the default alignment is not being honoured. When I start typing the text is aligned left regardless how I’ve set it up. Using the debugger I can check that the alignment is set to alignCenter. It works correctly if I turn off the multiline property.
I notice that the focus ring also disappears if the multiline property is set.
There’s a few other TextArea alignment issues recorded in the forum but not this particular one.
Does anyone have any ideas please. Cocoa seems to have changed a lot of this some of which I find fairly critical.
Alignment is not honored if you have HORIZONTAL Scrollbars enabled.
Sloweness is not a problem I’ve had… and I have new apps with lots of styled text.
Thanks for that.
Scrollbars are all off (horizontal and vertical).
I don’t think slowness is a problem with TextAreas. I thinks its more to draw with drawing the calendar and setting up captions. Works absolutely acceptably under Carbon, but very slow in Cocoa.
Which version of Xojo are you using for compiling?
I’m on 2013V3.3
I’ve just got it to partially work, I think.
What I’ve got is
me.alignment = TextArea.AlignCenter
I changed it to
me.SelAlignment = TextArea.AlignCenter
and this seems to work for at least one of the TextAreas. Still to try the others.
This doesn’t make much sense since it doesn’t use styled text, the field is empty and nothing is selected.
Still can’t get the FocusRing to work but I’ll keep working on it.
This is info for anyone who experiences a similar problem.
Ok … this app is building calendars. Depending on the chosen layout you can enter a caption for everyday of the year … “John’s Birthday”, “Christmas”, whatever. The text areas are created programmatically and not in the IDE. In setting these up, my code read
Select case fontAlign
dayCap.SelAlignment = TextField.AlignCenter
dayCap.SelAlignment = TextField.AlignRight
dayCap.SelAlignment = TextField.AlignLeft
dayCap.Bold = fontBold
dayCap.TextColor = fontColour
dayCap.Italic = fontItalic
dayCap.TextFont = fontName
dayCap.TextSize = fontSize
dayCap.Underline = fontUnderline
I watched the SELECT statement set the text alignment to AlignCenter and as soon as I clicked the button to execute
dayCap.Bold = fontBold
alignment immediately changed back to 0 (default).
I cut out the select statement and placed it after dayCap.Underline and everything worked fine.
I’m sure there’s a good reason why it works that way - would love to hear it.
the SELxxx functions are NOT exclusive to Styled Text… well some of them are not
SELSTART, SELLENGTH, SELALIGNMENT, SELTEXT… .the ones that affect font, size, color etc are.
I’ve revisited this calendar program to improve the printed output. I took the opportunity to clean up the code and make the whole process a lot slicker. The Alignment problem is still there as at Xojo v2016R1.1. Had to make sure the TextArea alignment property was set last of all AND I had to set SelAlign or the text was left aligned even although StyleText was turned off and regardless of how Alignment was set.
I had the same issue and, it seems I found a solution :
me.Alignment = TextArea.AlignCenter
It is the only way for me to center the text in a TextArea with the latest release of XOJO 2016 R1.1
Thanks for that. I can’t do what you suggest since my textareas are being created programmatically and the user can dynamically change the alignment. I think this is a bug in Xojo. To recap - this is a calendar generator. The user can add pictures, picture captions and a text caption on any day of the year. He can set up a set of default font attributes, font, size bold, italic etc and alignment. The program also maintains lists of captions - family birthdays, holidays etc that can be applied to any calendar. What I’m finding is that I have to assign the alignment option to textarea.alignment and textarea.selalignment to get it to work at all. If the text is on a single line it works, if it goes to 2 or more lines it is left aligned regardless. I can force it to centre by manually setting it to left and then centre again in my inspector window (part of the app).
You can create a TextArea control that uses the Open event, and then create programmatically your textarea with this control… ?