Italics question

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”
italics.caption = “Turn Italics ON”
text1.selitalic = false
end if

Also …
A sub runs this code …

text1.text = replaceall(text1.text, chr(8220),chr(34))
text1.text =replaceall(text1.text, chr(8221),chr(34))
text1.text =replaceall(text1.text, chr(8216),chr(39))
text1.text =replaceall(text1.text, chr(8217),chr(39))

… and that has the odd effect of un-italicizing whatever has been italicized … why? :frowning:

any help appreciated!

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.

Thanks Tim …

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.

Try this in the button action event:

text1.selItalic = not text1.selItalic

It will inverse the selection’s italics without relying on the button title.

Are the two environments the same between home and school?
Are you using a different font at school?
OS Version?

By the way, Mac is not an acronym :slight_smile:

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.

Thanks for all the responses … I’ll check everything out and get back to you all - many thanks gain for the prompt responses!


My “Mac” … OS X Yosemite (10.10.5)

School = OS X (10.9.5)

(BTW … I’m a PC guy until I moved to this new school - had to learn Mac-i-ness in a hurry … not so familiar)

I have not provided an option to change fonts … it opens on the default font.

Oh - wait … if I set the font on opening to Times New Roman then everything works fine …

So, I guess, the default font on the school Mac didn’t have any italics???

Thanks for all the input!!!

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.

Yup … I’m a little miffed at myself for not thinking “font” earlier … but that was a fun bug …

Thanks guys!!!