Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2004
    Posts
    11

    multiple "setvisable = false" how do I ....

    Hi,

    Is it possible to easily (and quickly ) set multiple "setvisible = false" actions to a button.

    I require that each of 10 buttons sets "setvisable = false" to 8 - 10 buttons on a page whilst similtainiously (sp) setting "setvisable = true" to another range of 8 - 10 buttons

    Looking for a way to do this without adding each action individually and cutting down on the actual code required to perform these action.

    Thanks again

    TeeDee

  2. #2
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    What I've done in the past is have each button end with a Numeric Value, like Button1 , Button2

    then use a for loop, concatate the loop variable to your button name.

    Add 10 buttons to a page leaving the buttons named Button1 through Button10. Set the visible property on some of them to false.

    Then use this code to swap the hidden buttons with the visible ones:

    for n=1, 10 do
    --hide all visible buttons and show all hidden
    Button.SetVisible("Button"..n,not Button.IsVisible("Button"..n))
    end

  3. #3
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    If you don't want to name your objects that way, there are two other methods you can use.

    1. Create a table containing the names of the objects you want to modify, and then use a for loop to walk through the table, showing or hiding all the objects in the list.

    2. Use Page.EnumerateObjects and Page.GetObjectType to operate on all the objects of a given type (e.g. all the buttons) on the page.

    Use method 1 if you don't want to modify all of the objects of that type on the page (e.g. you want to modify 8 out of 12 button objects). Use method 2 if you don't want to have to update the table whenever you add objects to the page or rename them.
    --[[ Indigo Rose Software Developer ]]

  4. #4
    Join Date
    Feb 2004
    Posts
    11
    Originally posted by Lorne
    1. Create a table containing the names of the objects you want to modify, and then use a for loop to walk through the table, showing or hiding all the objects in the list.
    That sounds more like I need, can you elaborate a little bit more how to do this, 1st time for me and I am reying to learn all this

    Thanks

    TeeDee

  5. #5
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Here's a function that uses method 2 to do a set visible on all the buttons on the current page.

    Code:
    AllButtons = {};
    function AllButtons.SetVisible(bVisible)
    	local tbObjects = Page.EnumerateObjects();
    	for index, name in tbObjects do
    		if Page.GetObjectType(name) == OBJECT_BUTTON then
    			Button.SetVisible(name,bVisible);
    		end
    	end	
    end
    Here's an example of calling that function:
    Code:
    -- show all buttons
    AllButtons.SetVisible(true);
    
    -- hide all buttons
    AllButtons.SetVisible(false);
    --[[ Indigo Rose Software Developer ]]

  6. #6
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Here's an example of method 1:

    Code:
    MyButtons = {"Button1","Button2","Button3"};
    function HideMyButtons()
    	for index, name in MyButtons do
    		Button.SetVisible(name,false);
    	end
    end
    
    function ShowMyButtons()
    	for index, name in MyButtons do
    		Button.SetVisible(name,true);
    	end
    end
    
    -- hide the buttons listed in the 'MyButtons' table
    HideMyButtons();
    --[[ Indigo Rose Software Developer ]]

  7. #7
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Here's a more advanced example that can handle different object types:

    Code:
    Objects = {};
    function Objects.SetVisible(tbObjectNames, bVisible)
    	for index, name in tbObjectNames do
    		local obtype = Page.GetObjectType(name);
    		if obtype == OBJECT_BUTTON then
    			Button.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_FLASH then
    			Flash.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_IMAGE then
    			Image.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_INPUT then
    			Input.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_LABEL then
    			Label.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_LISTBOX then
    			ListBox.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_PARAGRAPH then
    			Paragraph.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_PLUGIN then
    			Plugin.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_VIDEO then
    			Video.SetVisible(name, bVisible);
    		elseif obtype == OBJECT_WEB then
    			Web.SetVisible(name, bVisible);
    		else
    			Debug.Print("Error: "..name.." - Invalid object type.");
    		end
    	end
    end
    
    -- hide Button1, Button2 and Label5
    MyObjects = {"Button1","Button2","Label5"};
    Objects.SetVisible(MyObjects, false);
    --[[ Indigo Rose Software Developer ]]

  8. #8
    Join Date
    Feb 2004
    Posts
    11
    thanks, still trying to get my head around this so I can understand it.........

    any chance you could throw together a couple of working examples so I can see where the code goes (can't even seem to get that right :( )and what happems when I modify it ?

    Thanks again, I appreciiate the help.

    TeeDee

  9. #9
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Here you go. Be sure to look in the following places:

    Project > Global Functions
    Page - On Preload
    Button4 - On Click
    Button5 - On Click
    Attached Files
    --[[ Indigo Rose Software Developer ]]

  10. #10
    Join Date
    Feb 2004
    Posts
    11
    Thank you so much

    I find it so much easier to learn playing with a working version and then brealing it to suit my needs

    Thanks again

    TeeDee

Similar Threads

  1. rename multiple files
    By jenny62 in forum Setup Factory 6.0
    Replies: 1
    Last Post: 04-13-2004, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts