This function will show or hide all objects of a certain type on a page with just one call.
This code could easily be adjusted to apply any kind of action to objects on a page without knowing anything specific about the page you are working on. For example, to enable or disable objects or to change an object type's text.
Attached is a sample project that shows the code in use. The function is located in the Global Functions script.
Code:
-- Name: ShowHideObjectsOfType -- Purpose: To show or hide all objects of a certain type on a page -- Arguments: -- Type - (number) The type of object to work on. For a list of -- type constants, see the help file for Page.GetObjectType -- Show - (boolean) Whether to show (true) or hide (false) the object -- Returns: Nothing function ShowHideObjectsOfType(Type, Show) local tblObjects = Page.EnumerateObjects(); if tblObjects then for i,ObName in tblObjects do nTypeCurrent = Page.GetObjectType(ObName); if(nTypeCurrent == Type)then -- Matches the type we are looking for... if(nTypeCurrent == OBJECT_BUTTON)then Button.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_LABEL)then Label.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_PARAGRAPH)then Paragraph.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_IMAGE)then Image.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_FLASH)then Flash.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_VIDEO)then Video.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_WEB)then Web.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_INPUT)then Input.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_HOTSPOT)then -- Not applicable - do nothing elseif(nTypeCurrent == OBJECT_LISTBOX)then ListBox.SetVisible(ObName,Show); elseif(nTypeCurrent == OBJECT_PLUGIN)then Plugin.SetVisible(ObName,Show); end end end else -- Error Dialog.Message("Error", "Failed to enumerate objects: ".._tblErrorMessages[Application.GetLastError()]); end end
Attached is a sample project that shows the code in use. The function is located in the Global Functions script.