New to XOJO, but previously did OK with VB … I have a question about identifying italics …
I use the code below to turn on italics … and it works fine on my MAC, and fine when I “build” it … but it doesn’t work for the “textarea” when I use it on the built app at work. If I paste some text from a WORD document there, however, then subsequently the italics routine DOES work … confused!
if italics.caption = “Turn Italics ON” then
text1.selitalic = true
italics.caption = “Turn Italics OFF”
else
italics.caption = “Turn Italics ON”
text1.selitalic = false
end if
First, SelItalic only tells you if the selected text is italic.
Are you sure you have text selected, or are you trying to stylize the whole control?
You may find more reliability using StyleRuns. Providing us more details about your actions and your code would help.
About your secondary question, TextArea.Text only gives you the text value of the TextArea. There is no style information associated. TextArea.StyledText will give you the styled text information, with StyleRuns you can preserve or reverse.
There are several existing apps that will “wash” your clipboard if you’re trying to undo smart quotes and italics. You can also disable smart quotes on your text area with a declare for Mac.
I’ve made an app for my students … they have to, for example, italicize the name of a book in a sentence. As such, if the textarea has a sentence like the follow:
John read The Grapes of Wrath over the summer.
… then I simply highlight the part that reads ‘The Grapes of Wrath’ and the code I gave italicizes it … perfect … works great … but, seemingly, only on MY MAC … on the school’s MAC it just sits there unitalicized … which, i think … is odd … is it not?
I realize you’ve given a very full repsonse, so please forgive me if I respond to the various parts for the sake of simplicity.
It “may” have to do with installed fonts as well as the specific verison of OS.
a) Is the a CARBON or COCOA app? (if in latest version of XOJO then it would be COCOA, earlier you had a choice)
b) what OSX is on YOUR computer, and what OSX is on the School Computer?
c) What font is being used? Is it set by your app? can the user change it? etc.
On Mac, the font must support italics in order for it to display. Windows “cheats” it to make it appear more universal. I’m guessing the font you have installed at home supports italics, while the font on the school machine does not. School machines are notorious for being somewhat spartan in regards to what has/can be installed on them.