Showing, Hiding Objects
Beginner
from
JoeUser Forums
This is just really basic scripting know-how that I wanted to share before the next tutorial. Most of you probably know how already but every little bit helps, right?
Oftentimes I’ll see someone asking how to show or hide an object in various ways. You can do this pretty well through object properties already. For the sake of being thorough I’ll demonstrate that first.
Take 2 objects; “object1” & “object2”

Example 1:
Go to object1 Properties > General and change ‘Object Type’ to object controller – open/toggle – “object2”

Go to object2 Properties > Relation and change ‘Popup’ to toggle

Now when you click on object1 it will toggle object 2.
Example 2:
Change object1 back to a layer. Change object2’s popup back to static.
Go to object1 Properties > States, and add a mouse up state. Next, go to States > Messages and add a new message; object2 – hide. See picture below

Now when you click on object1 it will hide object2.
Alternatively, you could use a ‘show’ message instead:

That’s just the basics. There are several different ways for an object to popup or hide. You can make an object hide when another object pops up. You can hide an object by clicking anywhere else on your desktop. You can make an object show and hide like a pop up menu. This can be controlled in the target object’s Popup field and is explained in the Developer’s Guide here (scroll down to Popups)-- Link
Now, onto scripting! Don’t get me wrong, object properties is extremely useful for simple tasks and when I don’t want an overload of scripts running, but one of the many reasons I favor scripting is because I can make all the adjustments in one place (often via copy and paste) as opposed to changing and keeping track of properties in different areas of 2 or more objects.
Now, remove all the messages from object1. Make sure it is a layer, and object2’s popup is set to ‘static’. Try these 2 different scripts in object1.
Hide OR show object2:
Sub Object_OnLbuttonUp(x,y,d)
If Not d Then
Desktopx.object("object2").visible= false
End If
End Sub
Toggle object2 (show & hide)
Sub Object_OnLbuttonUp(x,y,d)
If Not d Then
'Check object's visibility, if it's showing or hidden
Select Case desktopx.object("object2").visible
'If showing, set variable to false
Case True
Showhide = False
'If hidden, set variable to true
Case False
Showhide = True
End Select
'Set object's visibilty to variable
Desktopx.object("object2").visible= showhide
End If
End Sub
Well that’s that. More to come. See ya!
Oh yeah, if you want to find various scripts online visit this growing DesktopX wiki here—
Link
Oftentimes I’ll see someone asking how to show or hide an object in various ways. You can do this pretty well through object properties already. For the sake of being thorough I’ll demonstrate that first.
Take 2 objects; “object1” & “object2”

Example 1:
Go to object1 Properties > General and change ‘Object Type’ to object controller – open/toggle – “object2”

Go to object2 Properties > Relation and change ‘Popup’ to toggle

Now when you click on object1 it will toggle object 2.
Example 2:
Change object1 back to a layer. Change object2’s popup back to static.
Go to object1 Properties > States, and add a mouse up state. Next, go to States > Messages and add a new message; object2 – hide. See picture below

Now when you click on object1 it will hide object2.
Alternatively, you could use a ‘show’ message instead:

That’s just the basics. There are several different ways for an object to popup or hide. You can make an object hide when another object pops up. You can hide an object by clicking anywhere else on your desktop. You can make an object show and hide like a pop up menu. This can be controlled in the target object’s Popup field and is explained in the Developer’s Guide here (scroll down to Popups)-- Link
Now, onto scripting! Don’t get me wrong, object properties is extremely useful for simple tasks and when I don’t want an overload of scripts running, but one of the many reasons I favor scripting is because I can make all the adjustments in one place (often via copy and paste) as opposed to changing and keeping track of properties in different areas of 2 or more objects.
Now, remove all the messages from object1. Make sure it is a layer, and object2’s popup is set to ‘static’. Try these 2 different scripts in object1.
Hide OR show object2:
Sub Object_OnLbuttonUp(x,y,d)
If Not d Then
Desktopx.object("object2").visible= false
End If
End Sub
Toggle object2 (show & hide)
Sub Object_OnLbuttonUp(x,y,d)
If Not d Then
'Check object's visibility, if it's showing or hidden
Select Case desktopx.object("object2").visible
'If showing, set variable to false
Case True
Showhide = False
'If hidden, set variable to true
Case False
Showhide = True
End Select
'Set object's visibilty to variable
Desktopx.object("object2").visible= showhide
End If
End Sub
Well that’s that. More to come. See ya!
Oh yeah, if you want to find various scripts online visit this growing DesktopX wiki here—
Link