Trigger

Cadcorp SIS Desktop commands fire triggers which can be monitored by GisLink applications.

One-shot commands have Succeeded and Failed triggers. CallBack commands may have Snap, KeyBack, KeyEnter, KeyTab and End triggers.

Note: All triggers fired in Cadcorp SIS Desktop are shown in the Developer Control Bar

A trigger can be added to GisLink code by declaring a TriggerHandler which points to a Sub procedure to be called from the trigger event.

Trigger names are always case-sensitive.

Each unique trigger should be added only once to a GisLink application. Triggers which are no longer required should be removed from the GisLink application.

Example

In the following example an item group is created in GisLink code. The item group contains a BoxText.

  • The user is asked for position input when the item in the group is updated.
  • The placement of a group requires two position inputs. A first input defines the location and the second user input defines the angle of the group.
  • For this application the developer would like to place groups with a single position input (not allowing the user to set an angle for the group).
  • The first position input will fire a trigger (AComPlaceGroup::Snap). The TriggerHandler will call a Sub procedure when the trigger is caught. The address of the Sub procedure is defined in the TriggerHandler:
SIS.CreateGroup("")

SIS.CreateBoxText(0, 0, 0, Label_font.Size * 0.0003527, Label_txt)

SIS.SetStr(SIS_OT_CURITEM, 0, "_font$", Label_font.Name)

SIS.SetInt(SIS_OT_CURITEM, 0, "_text_bold&", Label_font.Bold)

SIS.SetInt(SIS_OT_CURITEM, 0, "_text_italic&", Label_font.Italic)

SIS.SetStr(SIS_OT_CURITEM, 0, "_pen$", "<Pen><Colour><RGBA>0 0 0 0</RGBA></Colour></Pen>")

SIS.SetInt(SIS_OT_CURITEM, 0, "_text_alignH&", Label_alignment)

SIS.UpdateItem()

APP.AddTrigger("AComPlaceGroup::Snap", New SisTriggerHandler(AddressOf PlaceGroup_Snap))

The trigger is removed inside the Sub procedure which is called from the TriggerHandler. The SendKeys (Enter) method is used to emulate a key press which will confirm that no angle should be set on the placed item group.

Private Sub PlaceGroup_Snap(ByVal sender AsObject, ByVal e As SisTriggerArgs)

Try

    SendKeys.SendWait("{ENTER}")

    APP.RemoveTrigger("AComPlaceGroup::Snap", AddressOf PlaceGroup_Snap)

Catch ex As Exception

End Try

End Sub