Focus sensitive scripts handle selection in navigator when navigator is in focus, or current designer selection (e.g. current article or page etc) when designer is in focus.
Example of Publish scripts in Ted4
In Ted4MainAddIn class of Ted.vb there's the script ShowPublishDialog.
<ShellCommand(CanExecute:="Ena_HasSelection")> _
Public Sub ShowPublishDialog()
MyBase.Publish(Nothing, False)
End Sub
In TxtDesignerAddIn of Article.vb, there's the script with the same name:
Public Sub ShowPublishDialog()
Dim publishDialog As New PublishDialog(Designer.Main.Window)
publishDialog.AddObjectIds.Add(Ted.GetActiveArticle.Id)
publishDialog.IsUnpublishBeforePublish = False 'isUnpublishBeforePublish
If publishDialog.ShowDialog() = True Then
' Designer.Main.Refresh()
End If
End Sub
The menu command/toolbar icon points to ShowPublishDialog script. Automatically, the Ted.vb script runs when there's a selection on navigator, and navigator is in focus, while Article.vb script runs when the article is opened and article tree or text editing is in focus.
Example of EditArticleNotes
In Ted4MainAddIn class of Ted.vb there's the script EditArticleNotes:
Public Overloads Sub EditArticleNotes()
Dim selectedObjects As IGenericAttrObjList = Main.GetSelectedObjects
If selectedObjects.IsKindOf("article") Then
Dim editDialog As EditObjDialog = New EditObjDialog(Main.Window)
editDialog.SetIds(selectedObjects.Ids, "EditArticleNotes")
editDialog.SizeToContent = SizeToContent.WidthAndHeight
editDialog.Title = "Edit Notes"
editDialog.MinWidth = 300
editDialog.MinHeight = 250
If editDialog.ShowDialog() = True Then
Main.Refresh()
End If
End If
In TxtDesignerAddIn of Article.vb, there's the script with the same name:
Public Sub EditArticleNotes()
Dim ids(0) As Integer
ids(0) = Ted.GetActiveArticle.Id
Dim editDialog As EditObjDialog = New EditObjDialog(TedApp.AppBase.Windows.Item(0))
editDialog.SetIds(ids, "EditArticleNotes")
editDialog.SizeToContent = SizeToContent.WidthAndHeight
editDialog.Title = "Edit Notes"
editDialog.MinWidth = 300
editDialog.MinHeight = 250
editDialog.ShowDialog()
End Sub