Description
Toggle the current font style from not italic to italic and opposite, inserting or removing the >it 1< tag.
Syntax
Text.ToggleFontItalic |
Return value
Error code
Context
Text designer commands
See also
Customizations
Note: the following assumes that in all your formats are available the custom character styles with the tag and style name bold, with the tag and style name italic, and with the tag and style name bolditalic.
You can customize the default action, by adding an override in the CustomTxtDesignerAddIn class of the CustomArticle.vb. Instead to apply the >bd 1< tag, it will apply the >bold< character style:
<ShellCommand(CanExecute:="Ena_IsEditingArticleText", IsChecked:="Chk_IsToggleFontItalicChecked")>
Public Overridable Sub ToggleFontItalic()
Dim cMode As Short = 1
Dim bRestoreSelection As Boolean = False
Dim oBegSel As Cursor = Nothing
Dim oEndSel As Cursor = Nothing
If Text.TestTextSelection Then
bRestoreSelection = True
oBegSel = Text.GetCursor(cMode, 3, True)
oEndSel = Text.GetCursor(cMode, 4, True)
End If
if text.testshowcmd then Text.EditBlockNoCmd()
If Text.TestTextStyle("bolditalic") Then
Text.setStyleex(false,"bold",false,true)
ElseIf Text.TestTextStyle("italic") Then
Text.TxtStyle("")
ElseIf Text.testtextstyle("bold") Then
Text.setStyleEx(false,"bolditalic",false,true)
Else
Text.SetStyleEx(false,"italic",false,true)
End If
If bRestoreSelection Then ' restore the selection as it was
If Not oBegSel Is Nothing AndAlso Not oEndSel Is Nothing Then
Text.CursorTo(oBegSel)
Text.EditBlockStart()
Text.CursorTo(oEndSel)
Text.EditBlockEnd()
End If
End If
End Sub
Note: this script will override the system script and therefore provide for a custom action while editing text on the Articles main tab. In order to have the same customization available also when editing text on page, duplicate the same script also in the CustomPageTxtDesignerAddIn. class of the CustomPage.vb.